add space in multiword model in I18n unauthorized message - closes #292
This commit is contained in:
parent
951d70e057
commit
ba999970b1
|
@ -206,7 +206,7 @@ module CanCan
|
||||||
def unauthorized_message(action, subject)
|
def unauthorized_message(action, subject)
|
||||||
keys = unauthorized_message_keys(action, subject)
|
keys = unauthorized_message_keys(action, subject)
|
||||||
variables = {:action => action.to_s}
|
variables = {:action => action.to_s}
|
||||||
variables[:subject] = (subject.class == Class ? subject : subject.class).to_s.downcase
|
variables[:subject] = (subject.class == Class ? subject : subject.class).to_s.underscore.humanize.downcase
|
||||||
message = I18n.translate(nil, variables.merge(:scope => :unauthorized, :default => keys + [""]))
|
message = I18n.translate(nil, variables.merge(:scope => :unauthorized, :default => keys + [""]))
|
||||||
message.blank? ? nil : message
|
message.blank? ? nil : message
|
||||||
end
|
end
|
||||||
|
|
|
@ -395,6 +395,7 @@ describe CanCan::Ability do
|
||||||
it "should have variables for action and subject" do
|
it "should have variables for action and subject" do
|
||||||
I18n.backend.store_translations :en, :unauthorized => {:manage => {:all => "%{action} %{subject}"}} # old syntax for now in case testing with old I18n
|
I18n.backend.store_translations :en, :unauthorized => {:manage => {:all => "%{action} %{subject}"}} # old syntax for now in case testing with old I18n
|
||||||
@ability.unauthorized_message(:update, Array).should == "update array"
|
@ability.unauthorized_message(:update, Array).should == "update array"
|
||||||
|
@ability.unauthorized_message(:update, ArgumentError).should == "update argument error"
|
||||||
@ability.unauthorized_message(:edit, 1..3).should == "edit range"
|
@ability.unauthorized_message(:edit, 1..3).should == "edit range"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue
Block a user