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