mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-06 22:36:07 +00:00
Patching up the form and update to get form submission working
This commit is contained in:
@@ -95,7 +95,7 @@ GIT
|
||||
|
||||
GIT
|
||||
remote: git://github.com/willrjmarshall/foundation_rails_helper.git
|
||||
revision: 61ca053cea97c611dfd546bf7fcd846b98abd401
|
||||
revision: 4d5d53fdc4b1fb71e66524d298c5c635de82cfbb
|
||||
branch: rails3
|
||||
specs:
|
||||
foundation_rails_helper (0.4)
|
||||
|
||||
@@ -13,25 +13,26 @@ class Shop::CheckoutController < Spree::CheckoutController
|
||||
def update
|
||||
if @order.update_attributes(params[:order])
|
||||
fire_event('spree.checkout.update')
|
||||
|
||||
while @order.state != "complete"
|
||||
if @order.next
|
||||
state_callback(:after)
|
||||
else
|
||||
flash[:error] = t(:payment_processing_failed)
|
||||
respond_with @order, location: shop_checkout_path
|
||||
break
|
||||
respond_with @order, location: main_app.shop_checkout_path
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
if @order.state == "complete" || @order.completed?
|
||||
flash.notice = t(:order_processed_successfully)
|
||||
flash[:commerce_tracking] = "nothing special"
|
||||
respond_with(@order, :location => order_conf)
|
||||
respond_with(@order, :location => order_path(@order))
|
||||
else
|
||||
respond_with @order, location: shop_checkout_path
|
||||
respond_with @order, location: main_app.shop_checkout_path
|
||||
end
|
||||
else
|
||||
respond_with @order, location: shop_checkout_path
|
||||
respond_with @order, location: main_app.shop_checkout_path
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -7,10 +7,10 @@
|
||||
.row
|
||||
.large-6.columns
|
||||
= f.text_field :email
|
||||
= f.fields_for current_order.bill_address do |ba|
|
||||
= f.fields_for :bill_address do |ba|
|
||||
.large-6.columns
|
||||
= ba.text_field :phone
|
||||
= f.fields_for current_order.bill_address do |ba|
|
||||
= f.fields_for :bill_address do |ba|
|
||||
.row
|
||||
.large-6.columns
|
||||
= ba.text_field :firstname
|
||||
@@ -22,7 +22,7 @@
|
||||
= f.fields_for :bill_address do |ba|
|
||||
.row
|
||||
.large-12.columns
|
||||
= ba.text_field :address1
|
||||
= ba.text_field :address1, label: "Billing Address"
|
||||
.row
|
||||
.large-12.columns
|
||||
= ba.text_field :address2
|
||||
@@ -30,8 +30,10 @@
|
||||
.large-6.columns
|
||||
= ba.text_field :city
|
||||
.large-6.columns
|
||||
= ba.text_field :country
|
||||
= ba.select :country_id, Spree::Country.order(:name).select([:id, :name]).map{|c| [c.name, c.id]}
|
||||
.row
|
||||
.large-6.columns
|
||||
= ba.select :state_id, Spree::State.order(:name).select([:id, :name]).map{|c| [c.name, c.id]}
|
||||
.large-6.columns.right
|
||||
= ba.text_field :zipcode
|
||||
|
||||
@@ -42,11 +44,11 @@
|
||||
.row
|
||||
.large-12.columns
|
||||
%label
|
||||
= f.radio_button :shipping_method, ship_method.id,
|
||||
= f.radio_button :shipping_method_id, ship_method.id,
|
||||
text: ship_method.name,
|
||||
"ng-model" => "shipping_method",
|
||||
"ng-change" => "shippingMethodChanged()",
|
||||
"data-require-ship-address" => ship_method.require_ship_address
|
||||
= ship_method.name
|
||||
|
||||
= fields_for current_order.ship_address do |sa|
|
||||
#ship_address{"ng-show" => "require_ship_address"}
|
||||
|
||||
@@ -141,28 +141,44 @@ feature "As a consumer I want to check out my cart", js: true do
|
||||
choose(sm1.name)
|
||||
find("#ship_address").visible?.should be_true
|
||||
end
|
||||
end
|
||||
|
||||
describe "with payment methods" do
|
||||
let(:pm1) { create(:payment_method, distributors: [distributor]) }
|
||||
let(:pm2) { create(:payment_method, distributors: [distributor]) }
|
||||
describe "with payment methods" do
|
||||
let(:pm1) { create(:payment_method, distributors: [distributor], name: "Roger rabbit", type: "Spree::PaymentMethod::Check") }
|
||||
let(:pm2) { create(:payment_method, distributors: [distributor]) }
|
||||
|
||||
before do
|
||||
pm1 # Lazy evaluation of ze create()s
|
||||
pm2
|
||||
visit "/shop/checkout"
|
||||
end
|
||||
before do
|
||||
pm1 # Lazy evaluation of ze create()s
|
||||
pm2
|
||||
visit "/shop/checkout"
|
||||
end
|
||||
|
||||
it "shows all available payment methods" do
|
||||
page.should have_content pm1.name
|
||||
page.should have_content pm2.name
|
||||
end
|
||||
it "shows all available payment methods" do
|
||||
page.should have_content pm1.name
|
||||
page.should have_content pm2.name
|
||||
end
|
||||
|
||||
describe "Purchasing" do
|
||||
it "re-renders with errors when we submit the incomplete form" do
|
||||
click_button "Purchase"
|
||||
current_path.should == "/shop/checkout"
|
||||
page.should have_content "can't be blank"
|
||||
describe "Purchasing" do
|
||||
it "re-renders with errors when we submit the incomplete form" do
|
||||
click_button "Purchase"
|
||||
current_path.should == "/shop/checkout"
|
||||
page.should have_content "can't be blank"
|
||||
end
|
||||
|
||||
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 pm1.name
|
||||
click_button "Purchase"
|
||||
page.should have_content "Your order has been processed successfully"
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user