Fix enforce_available_locales leak between tests

Even if it doesn't seem to have consequences right now, we certainly
prefer other tests to use the default value.
This commit is contained in:
Javi Martín
2021-08-11 05:20:14 +02:00
parent 071bcb7023
commit 5b6dc9d7ff

View File

@@ -41,13 +41,19 @@ describe "I18n" do
I18n.backend.store_translations(I18n.default_locale, { test_plural: keys })
I18n.backend.store_translations(:zz, {})
I18n.enforce_available_locales = false
I18n.with_locale(:zz) do
I18n.fallbacks[:zz] << I18n.default_locale
default_enforce = I18n.enforce_available_locales
expect(I18n.t("test_plural", count: 0)).to eq("No comments")
expect(I18n.t("test_plural", count: 1)).to eq("1 comment")
expect(I18n.t("test_plural", count: 2)).to eq("2 comments")
begin
I18n.enforce_available_locales = false
I18n.with_locale(:zz) do
I18n.fallbacks[:zz] << I18n.default_locale
expect(I18n.t("test_plural", count: 0)).to eq("No comments")
expect(I18n.t("test_plural", count: 1)).to eq("1 comment")
expect(I18n.t("test_plural", count: 2)).to eq("2 comments")
end
ensure
I18n.enforce_available_locales = default_enforce
end
end