Patching up our checkout flow so we don't try to create shipments before we have valid shipping addresses

This commit is contained in:
Will Marshall
2014-02-28 13:41:02 +11:00
parent 86a8b926f3
commit 1d5addb06e
4 changed files with 55 additions and 30 deletions

View File

@@ -160,7 +160,7 @@ feature "As a consumer I want to check out my cart", js: true do
end
describe "Purchasing" do
pending "re-renders with errors when we submit the incomplete form" do
it "re-renders with errors when we submit the incomplete form" do
choose sm2.name
click_button "Purchase"
current_path.should == "/shop/checkout"
@@ -170,17 +170,20 @@ feature "As a consumer I want to check out my cart", js: true do
it "renders errors on the shipping method where appropriate"
it "takes us to the order confirmation page when we submit a complete form" do
fill_in "Customer E-Mail", with: "test@test.com"
fill_in "Phone", with: "0468363090"
fill_in "First Name", with: "Will"
fill_in "Last Name", with: "Marshall"
fill_in "Billing Address", with: "123 Your Face"
select "Australia", from: "Country"
select "Victoria", from: "State"
fill_in "City", with: "Melbourne"
fill_in "Zip Code", with: "3066"
choose sm1.name
choose sm2.name
choose pm1.name
within "#details" do
fill_in "First Name", with: "Will"
fill_in "Last Name", with: "Marshall"
save_and_open_page
fill_in "Billing Address", with: "123 Your Face"
select "Australia", from: "Country"
select "Victoria", from: "State"
fill_in "Customer E-Mail", with: "test@test.com"
fill_in "Phone", with: "0468363090"
fill_in "City", with: "Melbourne"
fill_in "Zip Code", with: "3066"
end
click_button "Purchase"
page.should have_content "Your order has been processed successfully"
end

View File

@@ -274,14 +274,20 @@ describe Spree::Order do
order.shipping_method = create(:shipping_method, require_ship_address: false)
order.ship_address.update_attribute :firstname, "will"
order.save
order.ship_address.firstname.should == distributor.address.firstname
order.ship_address.firstname.shoul == distributor.address.firstname
end
it "does not populate the shipping address if the shipping method requires a delivery address" do
order.shipping_method = create(:shipping_method, require_ship_address: true)
order.ship_address.update_attribute :firstname, "will"
order.save
order.ship_address.firstname.should == "will"
end
it "doesn't attempt to create a shipment if the order is not yet valid" do
#Shipment.should_not_r
order.create_shipment!
end
end
end