mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-24 20:36:49 +00:00
Merge pull request #7048 from andrewpbrett/fix-sub-manifests
Verify line item when placing sub order (Fix #6680)
This commit is contained in:
@@ -62,6 +62,12 @@ class SubscriptionPlacementJob < ActiveJob::Base
|
||||
unavailable_stock_lines_for(order).each do |line_item|
|
||||
changes[line_item.id] = changes[line_item.id] || line_item.quantity
|
||||
line_item.update(quantity: 0)
|
||||
|
||||
Spree::OrderInventory.new(order).verify(line_item, order.shipment)
|
||||
end
|
||||
if changes.present?
|
||||
order.line_items.reload
|
||||
order.update_order_fees!
|
||||
end
|
||||
changes
|
||||
end
|
||||
|
||||
@@ -98,8 +98,7 @@ module Spree
|
||||
inventory_unit.destroy
|
||||
removed_quantity += 1
|
||||
end
|
||||
|
||||
shipment.destroy if shipment.inventory_units.count == 0
|
||||
shipment.destroy if shipment.inventory_units.reload.count == 0
|
||||
|
||||
# removing this from shipment, and adding to stock_location
|
||||
if order.completed?
|
||||
|
||||
@@ -115,6 +115,18 @@ describe SubscriptionPlacementJob do
|
||||
expect(changes[line_item2.id]).to be 3
|
||||
expect(changes[line_item3.id]).to be 3
|
||||
end
|
||||
|
||||
context "and the order has been placed" do
|
||||
before do
|
||||
allow(order).to receive(:ensure_available_shipping_rates) { true }
|
||||
allow(order).to receive(:process_each_payment) { true }
|
||||
job.send(:place_order, order.reload)
|
||||
end
|
||||
|
||||
it "removes the unavailable items from the shipment" do
|
||||
expect(order.shipment.manifest.size).to eq 1
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user