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:
Maikel Linke
2024-07-02 15:40:06 +10:00
parent cb4e7d6fe3
commit 2e36c699f6

View File

@@ -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