Automatically copy shipping address from billing if none present

This commit is contained in:
Rob Harrington
2017-03-17 11:27:26 +11:00
parent 7d1fc8cbe1
commit 2a3fc8cfec
2 changed files with 12 additions and 3 deletions

View File

@@ -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)

View File

@@ -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'