From 2a3fc8cfec063c6bac193af7f1a69a48a083388b Mon Sep 17 00:00:00 2001 From: Rob Harrington Date: Fri, 17 Mar 2017 11:27:26 +1100 Subject: [PATCH] Automatically copy shipping address from billing if none present --- .../standing_order_controller.js.coffee | 1 + spec/features/admin/standing_orders_spec.rb | 14 +++++++++++--- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/app/assets/javascripts/admin/standing_orders/controllers/standing_order_controller.js.coffee b/app/assets/javascripts/admin/standing_orders/controllers/standing_order_controller.js.coffee index 5013634947..dee6ecedef 100644 --- a/app/assets/javascripts/admin/standing_orders/controllers/standing_order_controller.js.coffee +++ b/app/assets/javascripts/admin/standing_orders/controllers/standing_order_controller.js.coffee @@ -53,6 +53,7 @@ angular.module("admin.standingOrders").controller "StandingOrderController", ($s delete response.ship_address.id angular.extend($scope.standingOrder.bill_address, response.bill_address) angular.extend($scope.standingOrder.ship_address, response.ship_address) + $scope.shipAddressFromBilling() unless response.ship_address.address1? $scope.shipAddressFromBilling = => angular.extend($scope.standingOrder.ship_address, $scope.standingOrder.bill_address) diff --git a/spec/features/admin/standing_orders_spec.rb b/spec/features/admin/standing_orders_spec.rb index 2873fac8b9..b5af754427 100644 --- a/spec/features/admin/standing_orders_spec.rb +++ b/spec/features/admin/standing_orders_spec.rb @@ -157,10 +157,18 @@ feature 'Standing Orders' do expect(page).to have_input "bill_address_firstname", with: address.firstname expect(page).to have_input "bill_address_lastname", with: address.lastname expect(page).to have_input "bill_address_address1", with: address.address1 - click_button('Next') - expect(page).to have_content 'can\'t be blank', count: 7 # 7 because country is set on Spree::Address.default - # Setting the billing address + # Clear some elements of bill address + fill_in "bill_address_firstname", with: '' + fill_in "bill_address_lastname", with: '' + fill_in "bill_address_address1", with: '' + fill_in "bill_address_city", with: '' + fill_in "bill_address_zipcode", with: '' + fill_in "bill_address_phone", with: '' + click_button('Next') + expect(page).to have_content 'can\'t be blank', count: 6 + + # Re-setting the billing address fill_in "bill_address_firstname", with: 'Freda' fill_in "bill_address_lastname", with: 'Figapple' fill_in "bill_address_address1", with: '7 Tempany Lane'