Permalink
Browse files

[promo] make actions/create_line_items specs not depend on database o…

…rdering

See broken build #1419.6 for the problems this caused in the past
  • Loading branch information...
1 parent 177977d commit e21ef54cc1aabc32da86261d304a4e009bac95e1 @radar radar committed May 29, 2012
Showing with 9 additions and 6 deletions.
  1. +9 −6 promo/spec/models/promotion/actions/create_line_items_spec.rb
View
15 promo/spec/models/promotion/actions/create_line_items_spec.rb
@@ -22,22 +22,25 @@
it "adds line items to order with correct variant and quantity" do
action.perform(:order => order)
order.line_items.count.should == 2
- order.line_items.first.variant.should == @v1
- order.line_items.first.quantity.should == 1
+ line_item = order.line_items.find_by_variant_id(@v1.id)
+ line_item.should_not be_nil
+ line_item.quantity.should == 1
end
it "only adds the delta of quantity to an order" do
order.add_variant(@v2, 1)
action.perform(:order => order)
- order.line_items.first.variant.should == @v2
- order.line_items.first.quantity.should == 2
+ line_item = order.line_items.find_by_variant_id(@v2.id)
+ line_item.should_not be_nil
+ line_item.quantity.should == 2
end
it "doesn't add if the quantity is greater" do
order.add_variant(@v2, 3)
action.perform(:order => order)
- order.line_items.first.variant.should == @v2
- order.line_items.first.quantity.should == 3
+ line_item = order.line_items.find_by_variant_id(@v2.id)
+ line_item.should_not be_nil
+ line_item.quantity.should == 3
end
end

0 comments on commit e21ef54

Please sign in to comment.