Skip to content

Commit

Permalink
Remove deprecated methods Spree::Shipment#transfer_to_location and Sp…
Browse files Browse the repository at this point in the history
  • Loading branch information
DanielePalombo authored and kennyadsl committed Nov 17, 2020
1 parent 576280e commit 2ef76d8
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 41 deletions.
16 changes: 0 additions & 16 deletions core/app/models/spree/shipment.rb
Original file line number Diff line number Diff line change
Expand Up @@ -305,22 +305,6 @@ def update_state
end
end

def transfer_to_location(variant, quantity, stock_location)
Spree::Deprecation.warn("Please use the Spree::FulfilmentChanger class instead of Spree::Shipment#transfer_to_location", caller)
new_shipment = order.shipments.create!(stock_location: stock_location)
transfer_to_shipment(variant, quantity, new_shipment)
end

def transfer_to_shipment(variant, quantity, shipment_to_transfer_to)
Spree::Deprecation.warn("Please use the Spree::FulfilmentChanger class instead of Spree::Shipment#transfer_to_location", caller)
Spree::FulfilmentChanger.new(
current_shipment: self,
desired_shipment: shipment_to_transfer_to,
variant: variant,
quantity: quantity
).run!
end

def requires_shipment?
!stock_location || stock_location.fulfillable?
end
Expand Down
25 changes: 0 additions & 25 deletions core/spec/models/spree/shipment_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,31 +26,6 @@
let(:variant) { mock_model(Spree::Variant) }
let(:line_item) { mock_model(Spree::LineItem, variant: variant) }

context '#transfer_to_location' do
before do
allow(Spree::Deprecation).to receive(:warn).
with(/^Please use the Spree::FulfilmentChanger class instead of Spree::Shipment#transfer_to_location/, any_args)
end

it 'transfers unit to a new shipment with given location' do
order = create(:completed_order_with_totals, line_items_count: 2)
shipment = order.shipments.first
variant = order.inventory_units.map(&:variant).first

aggregate_failures("verifying new shipment attributes") do
expect do
shipment.transfer_to_location(variant, 1, stock_location)
end.to change { Spree::Shipment.count }.by(1)

new_shipment = order.shipments.order(:created_at).last
expect(new_shipment.number).to_not eq(shipment.number)
expect(new_shipment.stock_location).to eq(stock_location)
expect(new_shipment.line_items.count).to eq(1)
expect(new_shipment.line_items.first.variant).to eq(variant)
end
end
end

# Regression test for https://github.com/spree/spree/issues/4063
context "number generation" do
it "generates a number containing a letter + 11 numbers" do
Expand Down

0 comments on commit 2ef76d8

Please sign in to comment.