Order confirmation and order objects use overridden prices

This commit is contained in:
Rohan Mitchell
2014-12-19 16:19:56 +11:00
parent c3995ee4d5
commit 2bad590ef4

View File

@@ -4,6 +4,7 @@ feature "shopping with variant overrides defined", js: true do
include AuthenticationWorkflow
include WebHelper
include ShopWorkflow
include CheckoutWorkflow
include UIComponentHelper
use_short_wait
@@ -13,6 +14,8 @@ feature "shopping with variant overrides defined", js: true do
let(:producer) { create(:supplier_enterprise) }
let(:oc) { create(:simple_order_cycle, suppliers: [producer], coordinator: hub, distributors: [hub]) }
let(:outgoing_exchange) { oc.exchanges.outgoing.first }
let(:sm) { hub.shipping_methods.first }
let(:pm) { hub.payment_methods.first }
let(:p1) { create(:simple_product, supplier: producer) }
let(:p2) { create(:simple_product, supplier: producer) }
let(:v1) { create(:variant, product: p1, price: 11.11, unit_value: 1) }
@@ -24,6 +27,7 @@ feature "shopping with variant overrides defined", js: true do
let(:ef) { create(:enterprise_fee, enterprise: hub, fee_type: 'packing', calculator: Spree::Calculator::FlatPercentItemTotal.new(preferred_flat_percent: 10)) }
before do
ActionMailer::Base.deliveries.clear
outgoing_exchange.variants << v1
outgoing_exchange.variants << v2
outgoing_exchange.variants << v3
@@ -88,7 +92,54 @@ feature "shopping with variant overrides defined", js: true do
page.should have_selector 'form.edit_order .total', text: '$122.21'
end
it "creates the order with the correct prices"
it "creates the order with the correct prices" do
fill_in "variants[#{v1.id}]", with: "2"
show_cart
wait_until_enabled 'li.cart a.button'
click_link 'Quick checkout'
checkout_as_guest
within "#details" do
fill_in "First Name", with: "Some"
fill_in "Last Name", with: "One"
fill_in "Email", with: "test@example.com"
fill_in "Phone", with: "0456789012"
end
toggle_billing
within "#billing" do
fill_in "Address", with: "123 Street"
select "Australia", from: "Country"
select "Victoria", from: "State"
fill_in "City", with: "Melbourne"
fill_in "Postcode", with: "3066"
end
toggle_shipping
within "#shipping" do
choose sm.name
end
toggle_payment
within "#payment" do
choose pm.name
end
ActionMailer::Base.deliveries.length.should == 0
place_order
page.should have_content "Your order has been processed successfully"
ActionMailer::Base.deliveries.length.should == 2
email = ActionMailer::Base.deliveries.last
o = Spree::Order.complete.last
o.line_items.first.price.should == 55.55
o.total.should == 122.21
email.body.should include "$122.21"
end
it "subtracts stock from the override"
end
end