Skip to content

Commit

Permalink
Add a spec for #transfer_to_location to verify the attributes of the new
Browse files Browse the repository at this point in the history
shipment after the split.
  • Loading branch information
hectoregm committed May 16, 2016
1 parent fdad15b commit 39fd963
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions core/spec/models/spree/shipment_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,26 @@
let(:variant) { mock_model(Spree::Variant) }
let(:line_item) { mock_model(Spree::LineItem, variant: variant) }

context '#transfer_to_location' do
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.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
before { allow(order).to receive :update! }
Expand Down

0 comments on commit 39fd963

Please sign in to comment.