Skip to content

Commit

Permalink
Merge pull request #1141 from hectoregm/add_address_to_new_shipment_a…
Browse files Browse the repository at this point in the history
…fter_split

Add a spec for #transfer_to_location to verify the attributes of the new shipment
  • Loading branch information
jhawthorn authored Jun 29, 2016
2 parents bcdf549 + 39fd963 commit d3a9a67
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 @@ -23,6 +23,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 d3a9a67

Please sign in to comment.