From c9204b792c91bd7ec265b40e7066b6ae4145ed33 Mon Sep 17 00:00:00 2001 From: Matt Jankowski Date: Thu, 9 Nov 2023 04:46:39 -0500 Subject: [PATCH] Fix `Rails/I18nLocaleTexts` cop (#27779) --- .rubocop_todo.yml | 5 ----- lib/tasks/mastodon.rake | 6 +++++- spec/helpers/flashes_helper_spec.rb | 17 ++++++++++++----- 3 files changed, 17 insertions(+), 11 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 0e416482e79..b3228bac6e9 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -149,11 +149,6 @@ Rails/HasManyOrHasOneDependent: - 'app/models/user.rb' - 'app/models/web/push_subscription.rb' -Rails/I18nLocaleTexts: - Exclude: - - 'lib/tasks/mastodon.rake' - - 'spec/helpers/flashes_helper_spec.rb' - # Configuration parameters: Include. # Include: app/controllers/**/*.rb, app/mailers/**/*.rb Rails/LexicallyScopedActionFilter: diff --git a/lib/tasks/mastodon.rake b/lib/tasks/mastodon.rake index f2a90cd92e3..f50ef4bbff1 100644 --- a/lib/tasks/mastodon.rake +++ b/lib/tasks/mastodon.rake @@ -427,7 +427,11 @@ namespace :mastodon do from: env['SMTP_FROM_ADDRESS'], } - mail = ActionMailer::Base.new.mail to: send_to, subject: 'Test', body: 'Mastodon SMTP configuration works!' + mail = ActionMailer::Base.new.mail( + to: send_to, + subject: 'Test', # rubocop:disable Rails/I18nLocaleTexts + body: 'Mastodon SMTP configuration works!' + ) mail.deliver break rescue => e diff --git a/spec/helpers/flashes_helper_spec.rb b/spec/helpers/flashes_helper_spec.rb index 035e8a1de07..a6a3b062d7e 100644 --- a/spec/helpers/flashes_helper_spec.rb +++ b/spec/helpers/flashes_helper_spec.rb @@ -4,16 +4,23 @@ require 'rails_helper' describe FlashesHelper do describe 'user_facing_flashes' do - it 'returns user facing flashes' do + before do + # rubocop:disable Rails/I18nLocaleTexts flash[:alert] = 'an alert' flash[:error] = 'an error' flash[:notice] = 'a notice' flash[:success] = 'a success' flash[:not_user_facing] = 'a not user facing flash' - expect(helper.user_facing_flashes).to eq 'alert' => 'an alert', - 'error' => 'an error', - 'notice' => 'a notice', - 'success' => 'a success' + # rubocop:enable Rails/I18nLocaleTexts + end + + it 'returns user facing flashes' do + expect(helper.user_facing_flashes).to eq( + 'alert' => 'an alert', + 'error' => 'an error', + 'notice' => 'a notice', + 'success' => 'a success' + ) end end end