Skip to content
This repository has been archived by the owner on Sep 12, 2019. It is now read-only.

Commit

Permalink
Replace Spree.t in core models and specs
Browse files Browse the repository at this point in the history
  • Loading branch information
jhawthorn committed Nov 21, 2017
1 parent f2c84d3 commit 777b0f5
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 16 deletions.
8 changes: 4 additions & 4 deletions app/models/spree/stock_transfer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -85,15 +85,15 @@ 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

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
Expand All @@ -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
Expand Down
8 changes: 4 additions & 4 deletions app/models/spree/transfer_item.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,28 +22,28 @@ 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

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

Expand Down
6 changes: 3 additions & 3 deletions spec/models/spree/stock_transfer_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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

Expand Down
10 changes: 5 additions & 5 deletions spec/models/spree/transfer_item_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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

Expand Down

0 comments on commit 777b0f5

Please sign in to comment.