From ec61cff3876c1f1d32999f0d947d97895ebc1b2b Mon Sep 17 00:00:00 2001 From: Ahmed Ejaz Date: Sun, 7 Apr 2024 03:02:37 +0500 Subject: [PATCH] 12332 - Fix rubocop Rails/I18nLocaleTexts errors - Add en locales for the hardcodded strings --- .rubocop_todo.yml | 5 ----- app/controllers/admin/stripe_accounts_controller.rb | 6 +++--- config/locales/en.yml | 3 +++ 3 files changed, 6 insertions(+), 8 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 52b702e701..0c09f9ce14 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -576,11 +576,6 @@ Rails/HasManyOrHasOneDependent: - 'app/models/spree/tax_rate.rb' - 'app/models/spree/variant.rb' -# Offense count: 3 -Rails/I18nLocaleTexts: - Exclude: - - 'app/controllers/admin/stripe_accounts_controller.rb' - # Offense count: 22 # Configuration parameters: IgnoreScopes, Include. # Include: app/models/**/*.rb diff --git a/app/controllers/admin/stripe_accounts_controller.rb b/app/controllers/admin/stripe_accounts_controller.rb index b72175ac05..3b094adc5e 100644 --- a/app/controllers/admin/stripe_accounts_controller.rb +++ b/app/controllers/admin/stripe_accounts_controller.rb @@ -16,14 +16,14 @@ module Admin authorize! :destroy, stripe_account if stripe_account.deauthorize_and_destroy - flash[:success] = "Stripe account disconnected." + flash[:success] = I18n.t('stripe.success_code.disconnected') else - flash[:error] = "Failed to disconnect Stripe." + flash[:error] = I18n.t('stripe.error_code.disconnect_failure') end redirect_to main_app.edit_admin_enterprise_path(stripe_account.enterprise) rescue ActiveRecord::RecordNotFound - flash[:error] = "Failed to disconnect Stripe." + flash[:error] = I18n.t('stripe.error_code.disconnect_failure') redirect_to spree.admin_dashboard_path end diff --git a/config/locales/en.yml b/config/locales/en.yml index 3c3c1d1c1d..162f65d273 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -235,6 +235,9 @@ en: transaction_not_allowed: "The card has been declined for an unknown reason." try_again_later: "The card has been declined for an unknown reason." withdrawal_count_limit_exceeded: "The customer has exceeded the balance or credit limit available on their card." + disconnect_failure: "Failed to disconnect Stripe." + success_code: + disconnected: "Stripe account disconnected." activemodel: errors: