diff --git a/lib/capistrano/configuration/servers.rb b/lib/capistrano/configuration/servers.rb index 57d9faa3..bf3bf0c4 100644 --- a/lib/capistrano/configuration/servers.rb +++ b/lib/capistrano/configuration/servers.rb @@ -41,7 +41,7 @@ module Capistrano end def fetch_roles(names, options) - if Array(names).map(&:to_sym).include?(:all) + if Array(names).flatten.map(&:to_sym).include?(:all) filter(servers, options) else role_servers = Array(names).flat_map { |name| fetch name }.uniq @@ -70,7 +70,7 @@ module Capistrano if servers_with_filter.any? servers_with_filter else - fail I18n.t(:filter_removes_all_servers, scope: :capistrano, filter: key ) + fail I18n.t(:filter_removes_all_servers, scope: :capistrano, filter: key || '(no filter)' ) end end diff --git a/lib/capistrano/i18n.rb b/lib/capistrano/i18n.rb index 2afc81a9..93a07d5e 100644 --- a/lib/capistrano/i18n.rb +++ b/lib/capistrano/i18n.rb @@ -18,7 +18,7 @@ en = { mirror_exists: "The repository mirror is at %{at}", revision_log_message: 'Branch %{branch} deployed as release %{release} by %{user}', rollback_log_message: '%{user} rolled back to release %{release}', - filter_removes_all_servers: 'Your filter `:%{filter}` would remove all matching servers', + filter_removes_all_servers: 'Your filter `%{filter}` would remove all matching servers', console: { welcome: 'capistrano console - enter command to execute on %{stage}', bye: 'bye' diff --git a/lib/capistrano/tasks/deploy.rake b/lib/capistrano/tasks/deploy.rake index 142c84f2..cc448d74 100644 --- a/lib/capistrano/tasks/deploy.rake +++ b/lib/capistrano/tasks/deploy.rake @@ -59,7 +59,7 @@ namespace :deploy do namespace :symlink do desc 'Symlink release to current' task :release do - on roles([:web, :app]) do + on roles(:web, :app) do execute :rm, '-rf', current_path execute :ln, '-s', release_path, current_path end diff --git a/spec/integration/dsl_spec.rb b/spec/integration/dsl_spec.rb index 89539c16..5abd28c1 100644 --- a/spec/integration/dsl_spec.rb +++ b/spec/integration/dsl_spec.rb @@ -21,6 +21,13 @@ describe Capistrano::DSL do end end + describe 'fetching servers by multiple roles' do + it "does not confuse the last role with options" do + expect(dsl.roles(:app, :web).count).to eq 4 + expect(dsl.roles(:app, :web, filter: :active).count).to eq 2 + end + end + describe 'fetching servers by role' do subject { dsl.roles(:app) }