1
0
Fork 0
mirror of https://github.com/capistrano/capistrano synced 2023-03-27 23:21:18 -04:00

Merge pull request #1490 from maliqq/fix/match_server_different_ports

fix match server: different ports
This commit is contained in:
Lee Hambley 2016-01-20 07:33:19 +01:00
commit 526f77623d
4 changed files with 10 additions and 9 deletions

View file

@ -62,7 +62,7 @@ module Capistrano
end
def matches?(other)
hostname == other.hostname
hostname == other.hostname && port == other.port
end
private

View file

@ -11,7 +11,6 @@ module Capistrano
new_host = Server[host]
if (server = servers.find { |s| s.matches? new_host })
server.user = new_host.user if new_host.user
server.port = new_host.port if new_host.port
server.with(properties)
else
servers << new_host.with(properties)

View file

@ -273,22 +273,24 @@ describe Capistrano::DSL do
end
describe 'fetching all servers' do
it 'creates one server per hostname, ignoring user and port combinations' do
expect(dsl.roles(:all).size).to eq(1)
it 'creates one server per hostname, ignoring user combinations' do
expect(dsl.roles(:all).size).to eq(2)
end
end
describe 'fetching servers for a role' do
it 'roles defined using the `server` syntax are included' do
as = dsl.roles(:web).map { |server| "#{server.user}@#{server.hostname}:#{server.port}" }
expect(as.size).to eq(1)
expect(as[0]).to eq("deployer@example1.com:5678")
expect(as.size).to eq(2)
expect(as[0]).to eq("deployer@example1.com:1234")
expect(as[1]).to eq("@example1.com:5678")
end
it 'roles defined using the `role` syntax are included' do
as = dsl.roles(:app).map { |server| "#{server.user}@#{server.hostname}:#{server.port}" }
expect(as.size).to eq(1)
expect(as[0]).to eq("deployer@example1.com:5678")
expect(as.size).to eq(2)
expect(as[0]).to eq("deployer@example1.com:1234")
expect(as[1]).to eq("@example1.com:5678")
end
end

View file

@ -140,7 +140,7 @@ module Capistrano
servers.add_host('1', roles: [:app, 'web'], test: :value, user: 'root', port: 34)
servers.add_host('1', roles: [:app, 'web'], test: :value, user: 'deployer', port: 34)
servers.add_host('1', roles: [:app, 'web'], test: :value, user: 'deployer', port: 56)
expect(servers.count).to eq(1)
expect(servers.count).to eq(5)
end
describe "with a :user property" do