Special Instructions in checkout are actually wired up

This commit is contained in:
Rob H
2014-09-06 12:00:27 +10:00
parent 9dc2b248c7
commit b8fadb50ae
6 changed files with 32 additions and 25 deletions

View File

@@ -6,9 +6,9 @@ Darkswarm.controller "CheckoutCtrl", ($scope, storage, Checkout, CurrentUser, Cu
prefix = "order_#{Checkout.order.id}#{CurrentUser?.id}#{CurrentHub.hub.id}"
for field in $scope.fieldsToBind
storage.bind $scope, "Checkout.order.#{field}",
storage.bind $scope, "Checkout.order.#{field}",
storeName: "#{prefix}_#{field}"
storage.bind $scope, "Checkout.ship_address_same_as_billing",
storage.bind $scope, "Checkout.ship_address_same_as_billing",
storeName: "#{prefix}_sameasbilling"
defaultValue: true

View File

@@ -13,7 +13,7 @@ Darkswarm.factory 'Checkout', (CurrentOrder, ShippingMethods, PaymentMethods, $h
Loading.clear()
@errors = response.errors
RailsFlashLoader.loadFlash(response.flash)
# Rails wants our Spree::Address data to be provided with _attributes
preprocess: ->
munged_order = {}
@@ -25,7 +25,7 @@ Darkswarm.factory 'Checkout', (CurrentOrder, ShippingMethods, PaymentMethods, $h
munged_order["ship_address_attributes"] = value
when "payment_method_id"
munged_order["payments_attributes"] = [{payment_method_id: value}]
when "shipping_method_id", "payment_method_id", "email"
when "shipping_method_id", "payment_method_id", "email", "special_instructions"
munged_order[name] = value
else
# Ignore everything else
@@ -58,7 +58,7 @@ Darkswarm.factory 'Checkout', (CurrentOrder, ShippingMethods, PaymentMethods, $h
shippingPrice: ->
@shippingMethod()?.price || 0.0
paymentMethod: ->
PaymentMethods.payment_methods_by_id[@order.payment_method_id]

View File

@@ -9,7 +9,7 @@ class CheckoutController < Spree::CheckoutController
include OrderCyclesHelper
include EnterprisesHelper
def edit
# Because this controller doesn't inherit from our BaseController
# We need to duplicate the code here
@@ -56,7 +56,7 @@ class CheckoutController < Spree::CheckoutController
private
# Copied and modified from spree. Remove check for order state, since the state machine is
# progressed all the way in one go with the one page checkout.
def object_params
@@ -94,7 +94,7 @@ class CheckoutController < Spree::CheckoutController
def skip_state_validation?
true
end
def load_order
@order = current_order
redirect_to main_app.shop_path and return unless @order and @order.checkout_allowed?

View File

@@ -1,8 +1,8 @@
= f_form_for current_order, url: main_app.update_checkout_path,
= f_form_for current_order,
html: {name: "checkout",
id: "checkout_form",
novalidate: true,
name: "checkout"} do |f|
"ng-submit" => "purchase($event)"} do |f|
= inject_available_shipping_methods
= inject_available_payment_methods
@@ -20,7 +20,6 @@
= render partial: "checkout/payment", locals: {f: f}
%p
%button.button.primary{type: :submit,
"ng-click" => "purchase($event)",
"ng-disabled" => "checkout.$invalid"}
Place order now
/ {{ checkout.$valid }}

View File

@@ -7,7 +7,7 @@ feature %q{
}, skip: true do
include AuthenticationWorkflow
include WebHelper
background do
set_feature_toggle :order_cycles, true
@@ -24,8 +24,8 @@ feature %q{
:state => Spree::State.find_by_name('Victoria'),
:country => Spree::Country.find_by_name('Australia')),
:pickup_times => 'Tuesday, 4 PM')
@distributor_alternative = create(:distributor_enterprise, :name => 'Alternative Distributor',
:address => create(:address,
:address1 => '1600 Rathdowne St',
@@ -33,7 +33,7 @@ feature %q{
:zipcode => 3054,
:state => Spree::State.find_by_name('Victoria'),
:country => Spree::Country.find_by_name('Australia')),
:pickup_times => 'Tuesday, 4 PM')
:pickup_times => 'Tuesday, 4 PM')
@enterprise_fee_1 = create(:enterprise_fee, :name => 'Enterprise Fee One', :calculator => Spree::Calculator::PerItem.new)
@enterprise_fee_1.calculator.set_preference :amount, 1
@@ -347,16 +347,16 @@ feature %q{
login_to_consumer_section
click_link 'FruitAndVeg'
visit enterprise_path @distributor1
visit enterprise_path @distributor1
click_link 'Bananas'
click_button 'Add To Cart'
visit enterprise_path @distributor1
visit enterprise_path @distributor1
click_link 'Zucchini'
click_button 'Add To Cart'
find('#checkout-link').click
# And manually visit the old checkout
visit "/checkout"
@@ -389,7 +389,7 @@ feature %q{
# -- Checkout: Delivery
page.should have_content "DELIVERY METHOD"
order_charges = page.all("tbody#summary-order-charges tr").map {|row| row.all('td').map(&:text)}.take(2)
order_charges.should == [["Distribution:", "$51.00"]]
order_charges.should == [["Distribution:", "$51.00"]]
click_checkout_continue_button
@@ -403,7 +403,7 @@ feature %q{
# -- Checkout: Order complete
page.should have_content 'Your order has been processed successfully'
page.should have_content @payment_method_distributor_oc.description
page.should have_content @distributor_oc.name
page.should have_content @distributor_oc.name
page.should have_selector 'tfoot#order-charges tr.total td', text: 'Distribution'
page.should have_selector 'tfoot#order-charges tr.total td', text: '51.00'

View File

@@ -94,10 +94,6 @@ feature "As a consumer I want to check out my cart", js: true do
describe "purchasing" do
it "takes us to the order confirmation page when we submit a complete form" do
toggle_shipping
choose sm2.name
toggle_payment
choose pm1.name
toggle_details
within "#details" do
fill_in "First Name", with: "Will"
@@ -112,14 +108,25 @@ feature "As a consumer I want to check out my cart", js: true do
select "Victoria", from: "State"
fill_in "City", with: "Melbourne"
fill_in "Postcode", with: "3066"
end
toggle_shipping
within "#shipping" do
choose sm2.name
fill_in 'Any notes or custom delivery instructions?', with: "SpEcIaL NoTeS"
end
toggle_payment
within "#payment" do
choose pm1.name
end
place_order
page.should have_content "Your order has been processed successfully"
ActionMailer::Base.deliveries.length.should == 2
email = ActionMailer::Base.deliveries.last
site_name = Spree::Config[:site_name]
email.subject.should include "#{site_name} Order Confirmation"
o = Spree::Order.complete.first
expect(o.special_instructions).to eq "SpEcIaL NoTeS"
end
context "with basic details filled" do
@@ -157,6 +164,7 @@ feature "As a consumer I want to check out my cart", js: true do
it "takes us to the order confirmation page when submitted with a valid credit card" do
toggle_payment
save_screenshot '/Users/rob/Desktop/ss.png'
fill_in 'Card Number', with: "4111111111111111"
select 'February', from: 'secrets.card_month'
select (Date.today.year+1).to_s, from: 'secrets.card_year'