mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-13 23:37:47 +00:00
Merge pull request #12345 from chahmedejaz/task/12332-fix-rubocop-locale-errors
Fix Rubocop Locale Errors
This commit is contained in:
@@ -576,21 +576,6 @@ Rails/HasManyOrHasOneDependent:
|
||||
- 'app/models/spree/tax_rate.rb'
|
||||
- 'app/models/spree/variant.rb'
|
||||
|
||||
# Offense count: 8
|
||||
# Configuration parameters: Include.
|
||||
# Include: spec/**/*.rb, test/**/*.rb
|
||||
Rails/I18nLocaleAssignment:
|
||||
Exclude:
|
||||
- 'spec/controllers/user_registrations_controller_spec.rb'
|
||||
- 'spec/helpers/i18n_helper_spec.rb'
|
||||
- 'spec/models/spree/variant_spec.rb'
|
||||
- 'spec/system/admin/order_cycles/list_spec.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
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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:
|
||||
|
||||
@@ -96,6 +96,11 @@ RSpec.configure do |config|
|
||||
expectations.syntax = :expect
|
||||
end
|
||||
|
||||
# Reset locale for all specs.
|
||||
config.around(:each) do |example|
|
||||
I18n.with_locale(:en) { example.run }
|
||||
end
|
||||
|
||||
# Reset all feature toggles to prevent leaking.
|
||||
config.before(:suite) do
|
||||
Flipper.features.each(&:remove)
|
||||
|
||||
@@ -48,15 +48,9 @@ describe UserRegistrationsController, type: :controller do
|
||||
end
|
||||
|
||||
it "sets user.locale from cookie on create" do
|
||||
original_i18n_locale = I18n.locale
|
||||
original_locale_cookie = cookies[:locale]
|
||||
|
||||
cookies[:locale] = "pt"
|
||||
post :create, xhr: true, params: { spree_user: user_params, use_route: :spree }
|
||||
expect(assigns[:user].locale).to eq("pt")
|
||||
|
||||
I18n.locale = original_i18n_locale
|
||||
cookies[:locale] = original_locale_cookie
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -10,16 +10,6 @@ describe I18nHelper, type: :helper do
|
||||
allow(helper).to receive(:cookies) { cookies }
|
||||
end
|
||||
|
||||
# In the real world, the helper is called in every request and sets
|
||||
# I18n.locale to the chosen locale or the default. For testing purposes we
|
||||
# have to restore I18n.locale for unit tests that don't call the helper, but
|
||||
# rely on translated strings.
|
||||
around do |example|
|
||||
locale = I18n.locale
|
||||
example.run
|
||||
I18n.locale = locale
|
||||
end
|
||||
|
||||
context "as guest" do
|
||||
before do
|
||||
allow(helper).to receive(:spree_current_user) { nil }
|
||||
|
||||
@@ -59,17 +59,6 @@ describe Spree::Variant do
|
||||
end
|
||||
|
||||
context "price parsing" do
|
||||
before(:each) do
|
||||
I18n.locale = I18n.default_locale
|
||||
I18n.backend.store_translations(:de,
|
||||
{ number: { currency: { format: { delimiter: '.',
|
||||
separator: ',' } } } })
|
||||
end
|
||||
|
||||
after do
|
||||
I18n.locale = I18n.default_locale
|
||||
end
|
||||
|
||||
context "price=" do
|
||||
context "with decimal point" do
|
||||
it "captures the proper amount for a formatted price" do
|
||||
@@ -80,17 +69,19 @@ describe Spree::Variant do
|
||||
|
||||
context "with decimal comma" do
|
||||
it "captures the proper amount for a formatted price" do
|
||||
I18n.locale = :es
|
||||
variant.price = '1.599,99'
|
||||
expect(variant.price).to eq 1599.99
|
||||
I18n.with_locale(:es) do
|
||||
variant.price = '1.599,99'
|
||||
expect(variant.price).to eq 1599.99
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context "with a numeric price" do
|
||||
it "uses the price as is" do
|
||||
I18n.locale = :es
|
||||
variant.price = 1599.99
|
||||
expect(variant.price).to eq 1599.99
|
||||
I18n.with_locale(:es) do
|
||||
variant.price = 1599.99
|
||||
expect(variant.price).to eq 1599.99
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -133,9 +133,9 @@ describe '
|
||||
}
|
||||
|
||||
around(:each) do |spec|
|
||||
I18n.locale = :pt
|
||||
spec.run
|
||||
I18n.locale = :en
|
||||
I18n.with_locale(:pt) do
|
||||
spec.run
|
||||
end
|
||||
end
|
||||
|
||||
context 'using datetimepickers' do
|
||||
@@ -194,15 +194,6 @@ describe '
|
||||
|
||||
private
|
||||
|
||||
def wait_for_edit_form_to_load_order_cycle(order_cycle)
|
||||
expect(page).to have_field "order_cycle_name", with: order_cycle.name
|
||||
end
|
||||
|
||||
def select_incoming_variant(supplier, exchange_no, variant)
|
||||
page.find("table.exchanges tr.supplier-#{supplier.id} td.products").click
|
||||
check "order_cycle_incoming_exchange_#{exchange_no}_variants_#{variant.id}"
|
||||
end
|
||||
|
||||
def date_warning_msg(nbr = 1)
|
||||
"This order cycle is linked to %d open subscription orders. Changing this date now will not " \
|
||||
"affect any orders which have already been placed, but should be avoided if possible. " \
|
||||
|
||||
Reference in New Issue
Block a user