mirror of
https://github.com/capistrano/capistrano
synced 2023-03-27 23:21:18 -04:00
Issue #36 Fix problem in previous fixing : crash if find_servers is called with a ServerDefinition object
This commit is contained in:
parent
4a0f86de63
commit
c9f84f4936
2 changed files with 8 additions and 2 deletions
|
@ -39,8 +39,8 @@ module Capistrano
|
|||
# # returns the given hosts, translated to ServerDefinition objects
|
||||
# servers = find_servers :hosts => "jamis@example.host.com"
|
||||
def find_servers(options={})
|
||||
return [] if options.key?(:hosts) && (options[:hosts].nil? || options[:hosts] == [])
|
||||
return [] if options.key?(:roles) && (options[:roles].nil? || options[:roles] == [])
|
||||
return [] if options.key?(:hosts) && (options[:hosts].nil? || [] == options[:hosts])
|
||||
return [] if options.key?(:roles) && (options[:roles].nil? || [] == options[:roles])
|
||||
|
||||
hosts = server_list_from(ENV['HOSTS'] || options[:hosts])
|
||||
|
||||
|
|
|
@ -159,11 +159,17 @@ class ConfigurationServersTest < Test::Unit::TestCase
|
|||
def test_find_servers_with_hosts_nil_or_empty
|
||||
assert_equal [], @config.find_servers(:hosts => nil)
|
||||
assert_equal [], @config.find_servers(:hosts => [])
|
||||
result = @config.find_servers(:hosts => @config.find_servers(:roles => :report)[0])
|
||||
assert_equal 1, result.size
|
||||
result = @config.find_servers(:hosts => "app1")
|
||||
assert_equal 1, result.size
|
||||
end
|
||||
|
||||
def test_find_servers_with_rolees_nil_or_empty
|
||||
assert_equal [], @config.find_servers(:roles => nil)
|
||||
assert_equal [], @config.find_servers(:roles => [])
|
||||
result = @config.find_servers(:roles => :report)
|
||||
assert_equal 1, result.size
|
||||
end
|
||||
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue