Speed up add to cart: Update the order once per fee calculation, rather than for every line item x fee

This commit is contained in:
Rohan Mitchell
2016-01-07 10:52:36 +11:00
parent a27e593924
commit e24027a8d0
3 changed files with 38 additions and 10 deletions

View File

@@ -54,6 +54,8 @@ describe Spree::Order do
product_distribution.should_receive(:create_adjustment_for).with(line_item)
subject.stub(:product_distribution_for) { product_distribution }
subject.should_receive(:update!)
subject.update_distribution_charge!
end
@@ -65,6 +67,8 @@ describe Spree::Order do
subject.stub(:product_distribution_for) { nil }
subject.should_receive(:update!)
subject.update_distribution_charge!
end
@@ -90,6 +94,8 @@ describe Spree::Order do
OpenFoodNetwork::EnterpriseFeeCalculator.any_instance.stub(:create_order_adjustments_for)
subject.stub(:order_cycle) { order_cycle }
subject.should_receive(:update!)
subject.update_distribution_charge!
end