Ensure order total for uplaced subscription orders is zero

This commit is contained in:
Rob Harrington
2018-04-11 11:08:09 +10:00
committed by Maikel Linke
parent 50ffd7ca01
commit f5e77cdcec
2 changed files with 3 additions and 2 deletions

View File

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

View File

@@ -149,7 +149,8 @@ describe SubscriptionPlacementJob 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(order.adjustments).to be_empty
expect(order.total).to eq 0
expect(job).to_not have_received(:send_placement_email)
expect(job).to have_received(:send_empty_email)
end