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

correctly scope error message translation

This commit is contained in:
seenmyfate 2013-06-02 08:49:55 +01:00
parent e9494a9e2f
commit d546c9c1bf
3 changed files with 9 additions and 5 deletions

View file

@ -70,7 +70,7 @@ module Capistrano
if servers_with_filter.any? if servers_with_filter.any?
servers_with_filter servers_with_filter
else else
fail I18n.t(:filter_removes_all_servers) fail I18n.t(:filter_removes_all_servers, scope: :capistrano, filter: key )
end end
end end
@ -81,8 +81,12 @@ module Capistrano
@servers_with_filter ||= servers.select(&filter) @servers_with_filter ||= servers.select(&filter)
end end
def key
options[:filter] || options[:select]
end
def filter_option def filter_option
options[:filter] || options[:select] || all key || all
end end
def filter def filter

View file

@ -18,7 +18,7 @@ en = {
mirror_exists: "The repository mirror is at %{at}", mirror_exists: "The repository mirror is at %{at}",
revision_log_message: 'Branch %{branch} deployed as release %{release} by %{user}', revision_log_message: 'Branch %{branch} deployed as release %{release} by %{user}',
rollback_log_message: '%{user} rolled back to release %{release}', 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: { console: {
welcome: 'capistrano console - enter command to execute on %{stage}', welcome: 'capistrano console - enter command to execute on %{stage}',
bye: 'bye' bye: 'bye'

View file

@ -116,7 +116,7 @@ module Capistrano
end end
it 'raises if the filter would remove all matching hosts' do it 'raises if the filter would remove all matching hosts' do
I18n.expects(:t).with(:filter_removes_all_servers) I18n.expects(:t)
expect { servers.roles_for([:app, select: :inactive]) }.to raise_error expect { servers.roles_for([:app, select: :inactive]) }.to raise_error
end end
@ -137,7 +137,7 @@ module Capistrano
end end
it 'raises if the regular proc filter would remove all matching hosts' do it 'raises if the regular proc filter would remove all matching hosts' do
I18n.expects(:t).with(:filter_removes_all_servers) I18n.expects(:t)
expect { servers.roles_for([:app, select: lambda { |h| h.properties.inactive }])}.to raise_error expect { servers.roles_for([:app, select: lambda { |h| h.properties.inactive }])}.to raise_error
end end