Fix setting locale to an unavailable one in specs
When we assigned `I18n.available_locales = default_locales` in the `ensure` block, `I18n.locale` was set to `:zh-TW`, which is not one of the default locales. In some cases this resulted in tests failing: ``` I18n::InvalidLocale: :"zh-TW" is not a valid locale ```
This commit is contained in:
@@ -17,10 +17,11 @@ describe "rake db:seed" do
|
||||
welcome_level_three_verified: "welcome.welcome.title" }
|
||||
|
||||
I18n.available_locales.each do |locale|
|
||||
I18n.locale = locale
|
||||
paths.each do |slug, path|
|
||||
site = SiteCustomization::Page.find_by(slug: slug).translations.find_by(locale: locale)
|
||||
expect(site.title).to eq I18n.t(path)
|
||||
I18n.with_locale(locale) do
|
||||
paths.each do |slug, path|
|
||||
site = SiteCustomization::Page.find_by(slug: slug).translations.find_by(locale: locale)
|
||||
expect(site.title).to eq I18n.t(path)
|
||||
end
|
||||
end
|
||||
end
|
||||
ensure
|
||||
|
||||
Reference in New Issue
Block a user