Check for a `Hash` when using the `authentication_keys` to generate the FailureApp flash message.
Fixes #3270.
This commit is contained in:
parent
b910f5eb83
commit
a93edc72fd
|
@ -78,7 +78,9 @@ module Devise
|
|||
options[:resource_name] = scope
|
||||
options[:scope] = "devise.failure"
|
||||
options[:default] = [message]
|
||||
options[:authentication_keys] = scope_class.authentication_keys.join(I18n.translate(:"support.array.words_connector"))
|
||||
auth_keys = scope_class.authentication_keys
|
||||
keys = auth_keys.respond_to?(:keys) ? auth_keys.keys : auth_keys
|
||||
options[:authentication_keys] = keys.join(I18n.translate(:"support.array.words_connector"))
|
||||
options = i18n_options(options)
|
||||
|
||||
I18n.t(:"#{scope}.#{message}", options)
|
||||
|
|
|
@ -109,6 +109,13 @@ class FailureTest < ActiveSupport::TestCase
|
|||
assert_equal 'http://test.host/users/sign_in', @response.second["Location"]
|
||||
end
|
||||
|
||||
test 'supports authentication_keys as a Hash for the flash message' do
|
||||
swap Devise, authentication_keys: { email: true, login: true } do
|
||||
call_failure('warden' => OpenStruct.new(message: :invalid))
|
||||
assert_equal 'Invalid email, login or password.', @request.flash[:alert]
|
||||
end
|
||||
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]
|
||||
|
|
Loading…
Reference in New Issue