Permalink
Browse files

Fixes issue that causes order totals to be stale after calling Order#…

…add_variant.

Merges #1595
  • Loading branch information...
1 parent 9bf324e commit 0a995c078e22bed2cf731efacf8b72a104c2f1f5 @mscottford mscottford committed with radar May 24, 2012
@@ -287,6 +287,8 @@ def add_variant(variant, quantity = 1)
current_item.price = variant.price
self.line_items << current_item
end
+
+ self.reload
current_item
end
@@ -992,4 +992,18 @@ def compute(computable)
end
end
+ context "#add_variant" do
+ it "should update order totals" do
+ order = Spree::Order.create!
+
+ order.item_total.to_f.should == 0.00
+ order.total.to_f.should == 0.00
+
+ product = Spree::Product.create!(:name => 'Test', :sku => 'TEST-1', :price => 22.25)
+ order.add_variant(product.master)
+
+ order.item_total.to_f.should == 22.25
+ order.total.to_f.should == 22.25
+ end
+ end
end
@@ -38,14 +38,14 @@
click_link "Payments"
within('#payment_status') { page.should have_content("Payment: balance due") }
- find('table.index tbody tr:nth-child(2) td:nth-child(2)').text.should == "$39.98"
+ find('table.index tbody tr:nth-child(2) td:nth-child(2)').text.should == "$49.98"
find('table.index tbody tr:nth-child(2) td:nth-child(3)').text.should == "Credit Card"
find('table.index tbody tr:nth-child(2) td:nth-child(4)').text.should == "pending"
click_button "Void"
within('#payment_status') { page.should have_content("Payment: balance due") }
page.should have_content("Payment Updated")
- find('table.index tbody tr:nth-child(2) td:nth-child(2)').text.should == "$39.98"
+ find('table.index tbody tr:nth-child(2) td:nth-child(2)').text.should == "$49.98"
find('table.index tbody tr:nth-child(2) td:nth-child(3)').text.should == "Credit Card"
find('table.index tbody tr:nth-child(2) td:nth-child(4)').text.should == "void"

0 comments on commit 0a995c0

Please sign in to comment.