Clear adjustments on subs orders when no items are able to be fulfilled

This prevents shipping and payment fees from being displayed in the notification email
This commit is contained in:
Rob Harrington
2018-03-02 10:48:22 +11:00
committed by Maikel Linke
parent 514ad5d898
commit 50ffd7ca01
2 changed files with 3 additions and 1 deletions

View File

@@ -34,6 +34,7 @@ class SubscriptionPlacementJob
changes = cap_quantity_and_store_changes(order)
if order.line_items.where('quantity > 0').empty?
order.adjustments.destroy_all
return send_empty_email(order, changes)
end

View File

@@ -147,8 +147,9 @@ describe SubscriptionPlacementJob do
allow(job).to receive(:unavailable_stock_lines_for) { order.line_items }
end
it "does not place the order, sends an empty_order email" do
it "does not place the order, clears, all adjustments, and sends an empty_order email" do
expect{ job.send(:process, order) }.to_not change{ order.reload.completed_at }.from(nil)
expect(order.reload.adjustments).to be_empty
expect(job).to_not have_received(:send_placement_email)
expect(job).to have_received(:send_empty_email)
end