From b3ad5aeaca20d8be2196e32f07494b2fd43f0aee Mon Sep 17 00:00:00 2001 From: cyrillefr Date: Wed, 15 Feb 2023 10:42:01 +0100 Subject: [PATCH] Remove I18n keys in model specs --- spec/models/enterprise_spec.rb | 11 +++++++++-- spec/models/order_balance_spec.rb | 6 +++--- spec/models/product_importer_spec.rb | 6 +++--- spec/models/spree/order_spec.rb | 2 +- spec/models/spree/payment_method_spec.rb | 10 +++++----- spec/models/spree/return_authorization_spec.rb | 2 +- 6 files changed, 22 insertions(+), 15 deletions(-) diff --git a/spec/models/enterprise_spec.rb b/spec/models/enterprise_spec.rb index cbc26efa41..6055360bbd 100644 --- a/spec/models/enterprise_spec.rb +++ b/spec/models/enterprise_spec.rb @@ -136,14 +136,14 @@ describe Enterprise do it "prevents duplicate names for new records" do e = Enterprise.new name: enterprise.name expect(e).to_not be_valid - expect(e.errors[:name].first).to include I18n.t('enterprise_name_error', email: owner.email) + expect(e.errors[:name].first).to include enterprise_name_error(owner.email) end it "prevents duplicate names for existing records" do e = create(:enterprise, name: 'foo') e.name = enterprise.name expect(e).to_not be_valid - expect(e.errors[:name].first).to include I18n.t('enterprise_name_error', email: owner.email) + expect(e.errors[:name].first).to include enterprise_name_error(owner.email) end it "does not prohibit the saving of an enterprise with no name clash" do @@ -880,3 +880,10 @@ describe Enterprise do end end end + +def enterprise_name_error(owner_email) + "has already been taken. \ +If this is your enterprise and you would like to claim ownership, \ +or if you would like to trade with this enterprise please contact \ +the current manager of this profile at %s." % owner_email +end diff --git a/spec/models/order_balance_spec.rb b/spec/models/order_balance_spec.rb index 69411c5a63..95eec3219b 100644 --- a/spec/models/order_balance_spec.rb +++ b/spec/models/order_balance_spec.rb @@ -14,7 +14,7 @@ describe OrderBalance do end it "returns 'balance due'" do - expect(order_balance.label).to eq(I18n.t(:balance_due)) + expect(order_balance.label).to eq('Balance due') end end @@ -24,7 +24,7 @@ describe OrderBalance do end it "returns 'credit owed'" do - expect(order_balance.label).to eq(I18n.t(:credit_owed)) + expect(order_balance.label).to eq('Credit Owed') end end @@ -34,7 +34,7 @@ describe OrderBalance do end it "returns 'balance due'" do - expect(order_balance.label).to eq(I18n.t(:balance_due)) + expect(order_balance.label).to eq('Balance due') end end end diff --git a/spec/models/product_importer_spec.rb b/spec/models/product_importer_spec.rb index 3b415bf84a..812181e3e1 100644 --- a/spec/models/product_importer_spec.rb +++ b/spec/models/product_importer_spec.rb @@ -247,8 +247,8 @@ describe ProductImport::ProductImporter do # an unquoted \n will create a non valid line which will fail entry validation hence why we are only testing with \r it "should raise an unquoted field error if data include unquoted field with \r character" do expect(importer.errors.messages.values).to include( - [I18n.t('admin.product_import.model.malformed_csv', - error_message: "Unquoted fields do not allow new line <\"\\r\"> in line 3.")] + [format("Product Import encountered a malformed CSV: %s", + "Unquoted fields do not allow new line <\"\\r\"> in line 3.")] ) end end @@ -490,7 +490,7 @@ describe ProductImport::ProductImporter do expect(filter('invalid', entries)).to eq 2 importer.entries.each do |entry| - expect(entry.errors.messages.values).to include [I18n.t('admin.product_import.model.not_updatable')] + expect(entry.errors.messages.values).to include ['cannot be updated on existing products via product import'] end end end diff --git a/spec/models/spree/order_spec.rb b/spec/models/spree/order_spec.rb index 8c1adba511..6796b60280 100644 --- a/spec/models/spree/order_spec.rb +++ b/spec/models/spree/order_spec.rb @@ -1044,7 +1044,7 @@ describe Spree::Order do it "returns a validation error" do expect{ order.next }.to change(order.errors, :count).from(0).to(1) - expect(order.errors.messages[:email]).to eq [I18n.t('devise.failure.already_registered')] + expect(order.errors.messages[:email]).to eq ['This email address is already registered. Please log in to continue, or go back and use another email address.'] expect(order.state).to eq 'cart' end end diff --git a/spec/models/spree/payment_method_spec.rb b/spec/models/spree/payment_method_spec.rb index 67801a7d4c..32dba2f627 100644 --- a/spec/models/spree/payment_method_spec.rb +++ b/spec/models/spree/payment_method_spec.rb @@ -115,11 +115,11 @@ describe Spree::PaymentMethod do end it "generates a clean name for known Payment Method types" do - expect(Spree::PaymentMethod::Check.clean_name).to eq(I18n.t("spree.admin.payment_methods.providers.check")) - expect(Spree::Gateway::PayPalExpress.clean_name).to eq(I18n.t("spree.admin.payment_methods.providers.paypalexpress")) - expect(Spree::Gateway::StripeSCA.clean_name).to eq(I18n.t("spree.admin.payment_methods.providers.stripesca")) - expect(Spree::Gateway::BogusSimple.clean_name).to eq(I18n.t("spree.admin.payment_methods.providers.bogussimple")) - expect(Spree::Gateway::Bogus.clean_name).to eq(I18n.t("spree.admin.payment_methods.providers.bogus")) + expect(Spree::PaymentMethod::Check.clean_name).to eq('Cash/EFT/etc. (payments for which automatic validation is not required)') + expect(Spree::Gateway::PayPalExpress.clean_name).to eq('PayPal Express') + expect(Spree::Gateway::StripeSCA.clean_name).to eq('Stripe SCA') + expect(Spree::Gateway::BogusSimple.clean_name).to eq('BogusSimple') + expect(Spree::Gateway::Bogus.clean_name).to eq('Bogus') end it "computes the amount of fees" do diff --git a/spec/models/spree/return_authorization_spec.rb b/spec/models/spree/return_authorization_spec.rb index 760c496663..fb5bb41a3b 100644 --- a/spec/models/spree/return_authorization_spec.rb +++ b/spec/models/spree/return_authorization_spec.rb @@ -86,7 +86,7 @@ describe Spree::ReturnAuthorization do expect(Spree::Adjustment).to receive(:create).with( amount: -20, - label: I18n.t('spree.rma_credit'), + label: 'RMA credit', order: order, adjustable: order, originator: return_authorization