From 777b0f5b2cd5c8c3e0a533a00b21883017533bab Mon Sep 17 00:00:00 2001 From: John Hawthorn Date: Fri, 20 Oct 2017 13:09:35 -0700 Subject: [PATCH] Replace Spree.t in core models and specs --- app/models/spree/stock_transfer.rb | 8 ++++---- app/models/spree/transfer_item.rb | 8 ++++---- spec/models/spree/stock_transfer_spec.rb | 6 +++--- spec/models/spree/transfer_item_spec.rb | 10 +++++----- 4 files changed, 16 insertions(+), 16 deletions(-) diff --git a/app/models/spree/stock_transfer.rb b/app/models/spree/stock_transfer.rb index efd666e..636d1e5 100644 --- a/app/models/spree/stock_transfer.rb +++ b/app/models/spree/stock_transfer.rb @@ -72,7 +72,7 @@ def finalize(finalized_by) if finalizable? update_attributes({ finalized_at: Time.current, finalized_by: finalized_by }) else - errors.add(:base, Spree.t(:stock_transfer_cannot_be_finalized)) + errors.add(:base, I18n.t('spree.stock_transfer_cannot_be_finalized')) false end end @@ -85,7 +85,7 @@ def transfer end end rescue InvalidTransferMovement - errors.add(:base, Spree.t(:not_enough_stock)) + errors.add(:base, I18n.t('spree.not_enough_stock')) false end @@ -93,7 +93,7 @@ def close(closed_by) if receivable? update_attributes({ closed_at: Time.current, closed_by: closed_by }) else - errors.add(:base, Spree.t(:stock_transfer_must_be_receivable)) + errors.add(:base, I18n.t('spree.stock_transfer_must_be_receivable')) false end end @@ -102,7 +102,7 @@ def close(closed_by) def ensure_not_finalized if finalized? - errors.add(:base, Spree.t('errors.messages.cannot_delete_finalized_stock_transfer')) + errors.add(:base, I18n.t('spree.errors.messages.cannot_delete_finalized_stock_transfer')) throw :abort end end diff --git a/app/models/spree/transfer_item.rb b/app/models/spree/transfer_item.rb index a956f53..dcc497a 100644 --- a/app/models/spree/transfer_item.rb +++ b/app/models/spree/transfer_item.rb @@ -22,20 +22,20 @@ class TransferItem < Spree::Base def ensure_stock_transfer_not_closed if stock_transfer.closed? - errors.add(:base, Spree.t('errors.messages.cannot_modify_transfer_item_closed_stock_transfer')) + errors.add(:base, I18n.t('spree.errors.messages.cannot_modify_transfer_item_closed_stock_transfer')) end end def ensure_stock_transfer_not_finalized unless stock_transfer.finalizable? - errors.add(:base, Spree.t('errors.messages.cannot_delete_transfer_item_with_finalized_stock_transfer')) + errors.add(:base, I18n.t('spree.errors.messages.cannot_delete_transfer_item_with_finalized_stock_transfer')) throw :abort end end def prevent_expected_quantity_update_stock_transfer_finalized if expected_quantity_changed? && stock_transfer.finalized? - errors.add(:base, Spree.t('errors.messages.cannot_update_expected_transfer_item_with_finalized_stock_transfer')) + errors.add(:base, I18n.t('spree.errors.messages.cannot_update_expected_transfer_item_with_finalized_stock_transfer')) throw :abort end end @@ -43,7 +43,7 @@ def prevent_expected_quantity_update_stock_transfer_finalized def stock_availability stock_item = variant.stock_items.find_by(stock_location: stock_transfer.source_location) if stock_item.nil? || stock_item.count_on_hand < expected_quantity - errors.add(:base, Spree.t('errors.messages.transfer_item_insufficient_stock')) + errors.add(:base, I18n.t('spree.errors.messages.transfer_item_insufficient_stock')) end end diff --git a/spec/models/spree/stock_transfer_spec.rb b/spec/models/spree/stock_transfer_spec.rb index 0c56140..247212b 100644 --- a/spec/models/spree/stock_transfer_spec.rb +++ b/spec/models/spree/stock_transfer_spec.rb @@ -178,7 +178,7 @@ module Spree it "adds an error message" do subject - expect(stock_transfer.errors.full_messages).to include Spree.t(:stock_transfer_cannot_be_finalized) + expect(stock_transfer.errors.full_messages).to include I18n.t('spree.stock_transfer_cannot_be_finalized') end end end @@ -215,7 +215,7 @@ module Spree it "adds an error message" do subject - expect(stock_transfer.errors.full_messages).to include Spree.t(:stock_transfer_must_be_receivable) + expect(stock_transfer.errors.full_messages).to include I18n.t('spree.stock_transfer_must_be_receivable') end end end @@ -234,7 +234,7 @@ module Spree it "adds an error message to the model" do subject - expect(stock_transfer.errors.full_messages).to include Spree.t('errors.messages.cannot_delete_finalized_stock_transfer') + expect(stock_transfer.errors.full_messages).to include I18n.t('spree.errors.messages.cannot_delete_finalized_stock_transfer') end end diff --git a/spec/models/spree/transfer_item_spec.rb b/spec/models/spree/transfer_item_spec.rb index 0d1ed3b..5ed7f69 100644 --- a/spec/models/spree/transfer_item_spec.rb +++ b/spec/models/spree/transfer_item_spec.rb @@ -58,14 +58,14 @@ shared_examples_for 'availability check fails' do it "validates the availability" do subject - expect(transfer_item.errors.full_messages).to include Spree.t('errors.messages.transfer_item_insufficient_stock') + expect(transfer_item.errors.full_messages).to include I18n.t('spree.errors.messages.transfer_item_insufficient_stock') end end shared_examples_for 'availability check passes' do it "doesn't validate the availability" do subject - expect(transfer_item.errors.full_messages).to_not include Spree.t('errors.messages.transfer_item_insufficient_stock') + expect(transfer_item.errors.full_messages).to_not include I18n.t('spree.errors.messages.transfer_item_insufficient_stock') end end @@ -160,7 +160,7 @@ it "adds an error message" do subject - expect(transfer_item.errors.full_messages).to include Spree.t('errors.messages.cannot_modify_transfer_item_closed_stock_transfer') + expect(transfer_item.errors.full_messages).to include I18n.t('spree.errors.messages.cannot_modify_transfer_item_closed_stock_transfer') end end end @@ -178,7 +178,7 @@ it "adds an error message" do subject - expect(transfer_item.errors.full_messages).to include Spree.t('errors.messages.cannot_update_expected_transfer_item_with_finalized_stock_transfer') + expect(transfer_item.errors.full_messages).to include I18n.t('spree.errors.messages.cannot_update_expected_transfer_item_with_finalized_stock_transfer') end context "updating received_quantity" do @@ -215,7 +215,7 @@ it "adds an error message" do subject - expect(transfer_item.errors.full_messages).to include Spree.t('errors.messages.cannot_delete_transfer_item_with_finalized_stock_transfer') + expect(transfer_item.errors.full_messages).to include I18n.t('spree.errors.messages.cannot_delete_transfer_item_with_finalized_stock_transfer') end end