1
0
Fork 0
mirror of https://github.com/heartcombo/devise.git synced 2022-11-09 12:18:31 -05:00

Merge pull request #2112 from latortuga/patch-1

Make #set_flash_message respect i18n-set resource_name
This commit is contained in:
José Valim 2012-10-26 02:05:42 -07:00
commit 18c377e0d7
2 changed files with 7 additions and 1 deletions

View file

@ -168,7 +168,7 @@ MESSAGE
options[:default] = Array(options[:default]).unshift(kind.to_sym)
options[:resource_name] = resource_name
options = devise_i18n_options(options) if respond_to?(:devise_i18n_options, true)
message = I18n.t("#{resource_name}.#{kind}", options)
message = I18n.t("#{options[:resource_name]}.#{kind}", options)
flash[key] = message if message.present?
end

View file

@ -95,6 +95,12 @@ class HelpersTest < ActionController::TestCase
assert_equal 'devise custom options', flash[:notice]
end
test 'allows custom i18n options to override resource_name' do
I18n.expects(:t).with("custom_resource_name.confirmed", anything)
@controller.stubs(:devise_i18n_options).returns(:resource_name => "custom_resource_name")
@controller.send :set_flash_message, :notice, :confirmed
end
test 'navigational_formats not returning a wild card' do
MyController.send(:public, :navigational_formats)
Devise.navigational_formats = [:"*/*", :html]