mirror of
https://github.com/heartcombo/devise.git
synced 2022-11-09 12:18:31 -05:00
Ensure that the I18n backend is always initialized when we store custom translations.
Depending on the test order, there might a moment when a test reloads the I18n backend and another tries to store a translation, but since the backend wasn't re-initialized the custom translations would be overriden when i18n loads the translations from the en.yml file.
This commit is contained in:
parent
a6f3f8cb4a
commit
48f03d8cc4
1 changed files with 9 additions and 6 deletions
|
|
@ -8,12 +8,15 @@ class ActiveSupport::TestCase
|
|||
end
|
||||
|
||||
def store_translations(locale, translations, &block)
|
||||
begin
|
||||
I18n.backend.store_translations(locale, translations)
|
||||
yield
|
||||
ensure
|
||||
I18n.reload!
|
||||
end
|
||||
# Calling 'available_locales' before storing the translations to ensure
|
||||
# that the I18n backend will be initialized before we store our custom
|
||||
# translations, so they will always override the translations for the
|
||||
# YML file.
|
||||
I18n.available_locales
|
||||
I18n.backend.store_translations(locale, translations)
|
||||
yield
|
||||
ensure
|
||||
I18n.reload!
|
||||
end
|
||||
|
||||
def generate_unique_email
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue