diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index fe22385a7ff3d84cf7ffcbf12bbf89e648e6aa3e..171a11a0a1ad2dd0d7a43418a085f2a56a232d6a 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -1335,14 +1335,6 @@ Rails/HasManyOrHasOneDependent: - 'app/models/user.rb' - 'app/models/web/push_subscription.rb' -# Configuration parameters: Include. -# Include: spec/**/*.rb, test/**/*.rb -Rails/I18nLocaleAssignment: - Exclude: - - 'spec/controllers/auth/registrations_controller_spec.rb' - - 'spec/helpers/application_helper_spec.rb' - - 'spec/requests/localization_spec.rb' - Rails/I18nLocaleTexts: Exclude: - 'lib/tasks/mastodon.rake' diff --git a/spec/controllers/auth/registrations_controller_spec.rb b/spec/controllers/auth/registrations_controller_spec.rb index fffa7e06d74b669caaec9a2934d1e9d7b32ccfee..5c422bdffc3416758ace42c0ea5f003d358ab313 100644 --- a/spec/controllers/auth/registrations_controller_spec.rb +++ b/spec/controllers/auth/registrations_controller_spec.rb @@ -104,9 +104,9 @@ RSpec.describe Auth::RegistrationsController, type: :controller do end around do |example| - current_locale = I18n.locale - example.run - I18n.locale = current_locale + I18n.with_locale(I18n.locale) do + example.run + end end before { request.env['devise.mapping'] = Devise.mappings[:user] } diff --git a/spec/helpers/application_helper_spec.rb b/spec/helpers/application_helper_spec.rb index 88751548fc2c470a04482c5ada50aa0a7a1218f0..220eb2c80bd9754e449ef83599152482d331aa6a 100644 --- a/spec/helpers/application_helper_spec.rb +++ b/spec/helpers/application_helper_spec.rb @@ -44,30 +44,28 @@ describe ApplicationHelper do end describe 'locale_direction' do - around do |example| - current_locale = I18n.locale - example.run - I18n.locale = current_locale - end - it 'adds rtl body class if locale is Arabic' do - I18n.locale = :ar - expect(helper.locale_direction).to eq 'rtl' + I18n.with_locale(:ar) do + expect(helper.locale_direction).to eq 'rtl' + end end it 'adds rtl body class if locale is Farsi' do - I18n.locale = :fa - expect(helper.locale_direction).to eq 'rtl' + I18n.with_locale(:fa) do + expect(helper.locale_direction).to eq 'rtl' + end end it 'adds rtl if locale is Hebrew' do - I18n.locale = :he - expect(helper.locale_direction).to eq 'rtl' + I18n.with_locale(:he) do + expect(helper.locale_direction).to eq 'rtl' + end end it 'does not add rtl if locale is Thai' do - I18n.locale = :th - expect(helper.locale_direction).to_not eq 'rtl' + I18n.with_locale(:th) do + expect(helper.locale_direction).to_not eq 'rtl' + end end end diff --git a/spec/requests/localization_spec.rb b/spec/requests/localization_spec.rb index 39eeee5f01eeb7b30375a125f7f07f24b571b870..b7fb53ed8d7374dedf2c14c26f6f3c15ee105ec1 100644 --- a/spec/requests/localization_spec.rb +++ b/spec/requests/localization_spec.rb @@ -3,8 +3,10 @@ require 'rails_helper' describe 'Localization' do - after(:all) do - I18n.locale = I18n.default_locale + around do |example| + I18n.with_locale(I18n.locale) do + example.run + end end it 'uses a specific region when provided' do