From 49789c865e8393323b27db0ba7b3f2a0981fb024 Mon Sep 17 00:00:00 2001 From: Will Marshall Date: Tue, 18 Mar 2014 16:47:28 +1100 Subject: [PATCH] No longer copying old ship address from pickup, adding phone to custom shipping address --- app/controllers/spree/checkout_controller_decorator.rb | 2 +- app/views/shop/checkout/_form.html.haml | 3 +++ spec/controllers/shop/checkout_controller_spec.rb | 8 ++++++++ 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/app/controllers/spree/checkout_controller_decorator.rb b/app/controllers/spree/checkout_controller_decorator.rb index 3f83ca10ec..c0df48d456 100644 --- a/app/controllers/spree/checkout_controller_decorator.rb +++ b/app/controllers/spree/checkout_controller_decorator.rb @@ -45,7 +45,7 @@ Spree::CheckoutController.class_eval do past = Spree::Order.order("id desc").where(:email => email).where("state != 'cart'").limit(8) if order = past.detect(&:bill_address) bill_address = order.bill_address.clone if order.bill_address - ship_address = order.ship_address.clone if order.ship_address + ship_address = order.ship_address.clone if order.ship_address if order.shipping_method.require_ship_address end [bill_address, ship_address] diff --git a/app/views/shop/checkout/_form.html.haml b/app/views/shop/checkout/_form.html.haml index 1a5fc1cfe0..41f617a26f 100644 --- a/app/views/shop/checkout/_form.html.haml +++ b/app/views/shop/checkout/_form.html.haml @@ -106,6 +106,9 @@ = sa.text_field :firstname .large-6.columns = sa.text_field :lastname + .row + .large-6.columns + = sa.text_field :phone #ship_address_hidden{"ng-show" => "order.ship_address_same_as_billing"} = sa.hidden_field :address1, "ng-value" => "order.bill_address.address1", diff --git a/spec/controllers/shop/checkout_controller_spec.rb b/spec/controllers/shop/checkout_controller_spec.rb index 39f5cf9dff..2604fac5e7 100644 --- a/spec/controllers/shop/checkout_controller_spec.rb +++ b/spec/controllers/shop/checkout_controller_spec.rb @@ -37,6 +37,14 @@ describe Shop::CheckoutController do response.should be_success end + it "doesn't copy the previous shipping address from a pickup order" do + old_order = create(:order, bill_address: create(:address), ship_address: create(:address)) + old_order.shipping_method.should_receive(:require_ship_address).and_return(false) + Spree::Order.stub_chain(:order, :where, :where, :limit, :detect).and_return(old_order) + + controller.send(:find_last_used_addresses, "email").last.should == nil + end + describe "building the order" do before do controller.stub(:current_distributor).and_return(distributor)