mirror of
https://github.com/heartcombo/devise.git
synced 2026-01-09 14:58:05 -05:00
Pass locale with activatable / timeoutable hooks (#5815)
We need to explicitly pass the `locale` around from the options (passed to `warden.authenticate!` for instance) or the `I18n.locale` when logging out and redirecting the user via `throw :warden`, otherwise in a multi-locale app we'd lose the locale previously set / passed around and fallback to the default for that flash message. This is a follow-up of the fixes in #5567 where we implemented the locale passing logic down to the failure app, but it missed these places where we were using `throw :warden`. Closes #5812
This commit is contained in:
committed by
GitHub
parent
cd9c21a067
commit
051f94a498
@@ -136,6 +136,15 @@ class ConfirmationTest < Devise::IntegrationTest
|
||||
end
|
||||
end
|
||||
|
||||
test 'not confirmed user redirect respects i18n locale set' do
|
||||
swap Devise, allow_unconfirmed_access_for: 0.days do
|
||||
sign_in_as_user(confirm: false, visit: new_user_session_path(locale: "pt-BR"))
|
||||
|
||||
assert_contain 'Você precisa confirmar seu email para continuar'
|
||||
assert_not warden.authenticated?(:user)
|
||||
end
|
||||
end
|
||||
|
||||
test 'not confirmed user should not see confirmation message if invalid credentials are given' do
|
||||
swap Devise, allow_unconfirmed_access_for: 0.days do
|
||||
sign_in_as_user(confirm: false) do
|
||||
|
||||
@@ -167,6 +167,17 @@ class SessionTimeoutTest < Devise::IntegrationTest
|
||||
end
|
||||
end
|
||||
|
||||
test 'error message redirect respects i18n locale set' do
|
||||
user = sign_in_as_user
|
||||
|
||||
get expire_user_path(user)
|
||||
get root_path(locale: "pt-BR")
|
||||
follow_redirect!
|
||||
|
||||
assert_contain 'Sua sessão expirou. Por favor faça o login novamente para continuar.'
|
||||
assert_not warden.authenticated?(:user)
|
||||
end
|
||||
|
||||
test 'time out not triggered if remembered' do
|
||||
user = sign_in_as_user remember_me: true
|
||||
get expire_user_path(user)
|
||||
|
||||
Reference in New Issue
Block a user