Add and apply Rails/I18nLocaleAssignment rule

This rule was added in rubocop-rails 2.11.0.

Although we prevent I18n locale leaking between tests by setting it
before each test, the `with_locale` method makes the scope of the locale
change more obvious.
This commit is contained in:
Javi Martín
2021-08-11 05:16:06 +02:00
parent 2bfa9068f1
commit 071bcb7023
4 changed files with 27 additions and 16 deletions

View File

@@ -42,12 +42,13 @@ describe "I18n" do
I18n.backend.store_translations(:zz, {})
I18n.enforce_available_locales = false
I18n.locale = :zz
I18n.fallbacks[:zz] << I18n.default_locale
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")
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
end
it "returns count if specific plural rule not present" do