Add options for FailureApp's i18n_message. Similar #1633

This commit is contained in:
Benoit Bénézech
2013-10-24 16:46:45 +02:00
parent 8bef8b87f1
commit d5514bf916
3 changed files with 22 additions and 2 deletions

View File

@@ -8,6 +8,12 @@ class FailureTest < ActiveSupport::TestCase
end
end
class FailureWithI18nOptions < Devise::FailureApp
def i18n_options(options)
options.merge(:name => 'Steve')
end
end
def self.context(name, &block)
instance_eval(&block)
end
@@ -67,6 +73,11 @@ class FailureTest < ActiveSupport::TestCase
assert_equal 'http://test.host/users/sign_in', @response.second["Location"]
end
test 'uses custom i18n options' do
call_failure('warden' => OpenStruct.new(:message => :does_not_exist), :app => FailureWithI18nOptions)
assert_equal 'User Steve does not exist', @request.flash[:alert]
end
test 'uses the proxy failure message as string' do
call_failure('warden' => OpenStruct.new(:message => 'Hello world'))
assert_equal 'Hello world', @request.flash[:alert]