diff --git a/app/assets/javascripts/darkswarm/controllers/checkout/checkout_controller.js.coffee b/app/assets/javascripts/darkswarm/controllers/checkout/checkout_controller.js.coffee index 1197535033..81a852bd36 100644 --- a/app/assets/javascripts/darkswarm/controllers/checkout/checkout_controller.js.coffee +++ b/app/assets/javascripts/darkswarm/controllers/checkout/checkout_controller.js.coffee @@ -9,9 +9,10 @@ Darkswarm.controller "CheckoutCtrl", ($scope, storage, Checkout, CurrentUser, Cu for field in $scope.fieldsToBind storage.bind $scope, "Checkout.order.#{field}", storeName: "#{prefix}_#{field}" + storage.bind $scope, "Checkout.ship_address_same_as_billing", storeName: "#{prefix}_sameasbilling" - defaultValue: true + defaultValue: 'YES' $scope.order = Checkout.order # Ordering is important $scope.secrets = Checkout.secrets diff --git a/app/assets/javascripts/darkswarm/services/checkout.js.coffee b/app/assets/javascripts/darkswarm/services/checkout.js.coffee index 0ab94f61a4..2336de3382 100644 --- a/app/assets/javascripts/darkswarm/services/checkout.js.coffee +++ b/app/assets/javascripts/darkswarm/services/checkout.js.coffee @@ -3,7 +3,7 @@ Darkswarm.factory 'Checkout', (CurrentOrder, ShippingMethods, PaymentMethods, $h errors: {} secrets: {} order: CurrentOrder.order - ship_address_same_as_billing: true + ship_address_same_as_billing: 'YES' submit: -> Loading.message = t 'submitting_order' @@ -33,7 +33,7 @@ Darkswarm.factory 'Checkout', (CurrentOrder, ShippingMethods, PaymentMethods, $h else # Ignore everything else - if @ship_address_same_as_billing + if @ship_address_same_as_billing == 'YES' munged_order.ship_address_attributes = munged_order.bill_address_attributes # If the order already has a ship and bill address (as with logged in users with # past orders), and we don't remove id here, then this will set the wrong id for diff --git a/app/views/checkout/_shipping.html.haml b/app/views/checkout/_shipping.html.haml index 8bdc855b7a..97722d49a5 100644 --- a/app/views/checkout/_shipping.html.haml +++ b/app/views/checkout/_shipping.html.haml @@ -13,7 +13,7 @@ "ng-class" => "{valid: shipping.$valid, open: accordion.shipping}"} = render 'checkout/accordion_heading' - .small-12.columns.medium-6.columns.large-6.columns + .small-12.columns %label{"ng-repeat" => "method in ShippingMethods.shipping_methods"} %input{type: :radio, required: true, @@ -30,7 +30,7 @@ = "{{ fieldErrors('order.shipping_method_id') }}" %label{"ng-if" => "Checkout.requireShipAddress()"} - %input{type: :checkbox, "ng-model" => "Checkout.ship_address_same_as_billing"} + %input{type: :checkbox, "ng-model" => "Checkout.ship_address_same_as_billing", "ng-true-value" => "'YES'", "ng-false-value" => "'NO'"} = t :checkout_address_same .small-12.columns.medium-6.columns.large-6.columns diff --git a/app/views/checkout/_shipping_ship_address.html.haml b/app/views/checkout/_shipping_ship_address.html.haml index fa87eef2ff..9cddc6380b 100644 --- a/app/views/checkout/_shipping_ship_address.html.haml +++ b/app/views/checkout/_shipping_ship_address.html.haml @@ -1,6 +1,6 @@ .small-12.columns #ship_address{"ng-if" => "Checkout.requireShipAddress()"} - %div.visible{"ng-if" => "!Checkout.ship_address_same_as_billing"} + %div.visible{"ng-if" => "Checkout.ship_address_same_as_billing === 'NO'"} .row .small-6.columns = validated_input "First Name", "order.ship_address.firstname", "ofn-focus" => "accordion['shipping']" diff --git a/spec/javascripts/unit/darkswarm/controllers/checkout/checkout_controller_spec.js.coffee b/spec/javascripts/unit/darkswarm/controllers/checkout/checkout_controller_spec.js.coffee index d395ae9cc6..170d85ad88 100644 --- a/spec/javascripts/unit/darkswarm/controllers/checkout/checkout_controller_spec.js.coffee +++ b/spec/javascripts/unit/darkswarm/controllers/checkout/checkout_controller_spec.js.coffee @@ -62,7 +62,7 @@ describe "CheckoutCtrl", -> console.log prefix field = scope.fieldsToBind[0] expect(storage.bind).toHaveBeenCalledWith(scope, "Checkout.order.#{field}", {storeName: "#{prefix}_#{field}"}) - expect(storage.bind).toHaveBeenCalledWith(scope, "Checkout.ship_address_same_as_billing", {storeName: "#{prefix}_sameasbilling", defaultValue: true}) + expect(storage.bind).toHaveBeenCalledWith(scope, "Checkout.ship_address_same_as_billing", {storeName: "#{prefix}_sameasbilling", defaultValue: 'YES'}) it "it can retrieve data from localstorage", -> prefix = "order_#{scope.order.id}#{CurrentUser.id or ""}#{CurrentHubMock.hub.id}" diff --git a/spec/javascripts/unit/darkswarm/services/checkout_spec.js.coffee b/spec/javascripts/unit/darkswarm/services/checkout_spec.js.coffee index 43e83409ad..4d10592e91 100644 --- a/spec/javascripts/unit/darkswarm/services/checkout_spec.js.coffee +++ b/spec/javascripts/unit/darkswarm/services/checkout_spec.js.coffee @@ -126,9 +126,9 @@ describe 'Checkout service', -> expect(Checkout.preprocess().ship_address).toBe(undefined) it "munges the order attributes to clone ship address from bill address", -> - Checkout.ship_address_same_as_billing = false + Checkout.ship_address_same_as_billing = 'NO' expect(Checkout.preprocess().ship_address_attributes).toEqual(orderData.ship_address) - Checkout.ship_address_same_as_billing = true + Checkout.ship_address_same_as_billing = 'YES' expect(Checkout.preprocess().ship_address_attributes).toEqual(orderData.bill_address) it "creates attributes for card fields", ->