Browse files

Add mistakenly removed helpers from promotion_adjustments_spec back

  • Loading branch information...
1 parent 9208428 commit 5f3f0ae8699f084b4ea1a9c2bea66fa525d8b9cf @radar radar committed May 29, 2012
Showing with 54 additions and 0 deletions.
  1. +54 −0 promo/spec/requests/promotion_adjustments_spec.rb
View
54 promo/spec/requests/promotion_adjustments_spec.rb
@@ -346,6 +346,60 @@
Spree::Order.last.total.to_f.should == 55.00 # mug(40) - mug_discount(5) + bag(20) - bag_discount(10) + shipping(10)
end
+ it "should allow an admin to create a promotion that adds a 'free' item to the cart" do
+ fill_in "Name", :with => "Bundle"
+ select "Coupon code added", :from => "Event"
+ fill_in "Code", :with => "5ZHED2DH"
+ click_button "Create"
+ page.should have_content("Editing Promotion")
+
+ select "Create line items", :from => "Add action of type"
+ within('#action_fields') { click_button "Add" }
+ fill_in "Name or SKU", :with => "RoR Mug"
+ find(:xpath, '//div/h4[contains(.,"RoR Mug")]').click
+ within('.add-line-item') { click_button "Add" }
+
+ within('#actions_container') { click_button "Update" }
+
+ select "Create adjustment", :from => "Add action of type"
+ within('#new_promotion_action_form') { click_button "Add" }
+ select "Flat Rate (per order)", :from => "Calculator"
+ within('#actions_container') { click_button "Update" }
+ within('.calculator-fields') { fill_in "Amount", :with => "40.00" }
+ within('#actions_container') { click_button "Update" }
+
+ visit spree.root_path
+ click_link "RoR Bag"
+ click_button "Add To Cart"
+ click_link "Checkout"
+
+ str_addr = "bill_address"
+ fill_in "order_email", :with => "buyer@spreecommerce.com"
+ select "United States", :from => "order_#{str_addr}_attributes_country_id"
+ ['firstname', 'lastname', 'address1', 'city', 'zipcode', 'phone'].each do |field|
+ fill_in "order_#{str_addr}_attributes_#{field}", :with => "#{address.send(field)}"
+ end
+ select "#{address.state.name}", :from => "order_#{str_addr}_attributes_state_id"
+ check "order_use_billing"
+ click_button "Save and Continue"
+ click_button "Save and Continue"
+
+ choose('Credit Card')
+ fill_in "card_number", :with => "4111111111111111"
+ fill_in "card_code", :with => "123"
+
+ fill_in "order_coupon_code", :with => "5ZHED2DH"
+ click_button "Save and Continue"
+
+ last_order = Spree::Order.last
+ last_order.line_items.count.should == 2
+ last_order.line_items.first.price.to_f.should == 20.00
+ last_order.line_items.last.price.to_f.should == 40.00
+ last_order.item_total.to_f.should == 60.00
+ last_order.adjustments.promotion.map(&:amount).sum.to_f.should == -40.00
+ last_order.total.to_f.should == 30.00
+ end
+
it "ceasing to be eligible for a promotion with item total rule then becoming eligible again" do
fill_in "Name", :with => "Spend over $50 and save $5"
select "Order contents changed", :from => "Event"

0 comments on commit 5f3f0ae

Please sign in to comment.