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:
Javi Martín
2021-04-09 12:58:58 +02:00
parent 50deb6b353
commit 3b1072f3d1

View File

@@ -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