Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

fixed a bug in calculating amounts for promotions

  • Loading branch information...
commit 55fe842e24ab5dc54350ebcdbe985e1acb27df9f 1 parent 0e03e51
Michael Farmer mikefarmer authored
2  promo/lib/spree_promo/order_promotion.rb
View
@@ -123,7 +123,7 @@ def calculate_amounts
# {:line_item_id => line_item.id, :price => li.price}
calc.adjustable_line_items = adjustable_line_items
end
- coupon_item.amount = calc.compute(@order)
+ coupon_item.amount = calc.compute(@order) || 0
end
20 promo/spec/lib/spree_promo/order_promotion_spec.rb
View
@@ -258,6 +258,26 @@
end
+ describe "when items are removed from the order" do
+ it "should allow for an empty cart" do
+ order = Factory(:order)
+ order.add_variant(Factory(:variant))
+ coupon_code = @valid_codes.first
+ order.promo_codes = [coupon_code]
+ order.update!
+ order.save!
+
+ order.order_promo(true)[coupon_code].adjustment.should == 10
+
+ # empty
+ order.line_items.destroy_all
+ order.update!
+
+ order.order_promo(true)[coupon_code].adjustment.should == 0
+
+ end
+ end
+
end
Please sign in to comment.
Something went wrong with that request. Please try again.