mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-27 01:43:22 +00:00
Test resulting stock instead of method calls
The next test case wasn't asserting anything as well. The referenced method `decrease_stock_for_variant` doesn't actually exist.
This commit is contained in:
@@ -228,21 +228,15 @@ RSpec.describe Spree::Order do
|
||||
}.from(nil)
|
||||
end
|
||||
|
||||
it "should sell inventory units" do
|
||||
shipment = Spree::Shipment.new
|
||||
order.shipments = [shipment]
|
||||
it "updates shipments and decreases stock" do
|
||||
order = create(:order_ready_for_confirmation)
|
||||
shipment = order.shipments.first
|
||||
shipment.update_columns(updated_at: 1.minute.ago)
|
||||
|
||||
expect(shipment).to receive(:update!).with(order)
|
||||
expect(shipment).to receive(:finalize!)
|
||||
|
||||
order.finalize!
|
||||
end
|
||||
|
||||
it "should decrease the stock for each variant in the shipment" do
|
||||
order.shipments.each do |shipment|
|
||||
expect(shipment.stock_location).to receive(:decrease_stock_for_variant)
|
||||
end
|
||||
order.finalize!
|
||||
expect {
|
||||
order.finalize!
|
||||
}.to change { order.variants.first.on_hand }.by(-1)
|
||||
.and change { shipment.updated_at }
|
||||
end
|
||||
|
||||
it "should change the shipment state to ready if order is paid" do
|
||||
|
||||
Reference in New Issue
Block a user