From 7c50e1a41dd1989accb43abb6fd3cf352acb1d7a Mon Sep 17 00:00:00 2001 From: Will Marshall Date: Wed, 12 Mar 2014 17:17:07 +1100 Subject: [PATCH] Fixing up the specs --- .../controllers/checkout_controller.js.coffee | 3 ++- app/views/shop/checkout/_order.rabl | 5 ++++- spec/features/consumer/shopping/checkout_spec.rb | 4 ++-- spec/features/consumer/shopping/shopping_spec.rb | 10 ++-------- 4 files changed, 10 insertions(+), 12 deletions(-) diff --git a/app/assets/javascripts/darkswarm/controllers/checkout_controller.js.coffee b/app/assets/javascripts/darkswarm/controllers/checkout_controller.js.coffee index 54c949d247..a98c0bcd60 100644 --- a/app/assets/javascripts/darkswarm/controllers/checkout_controller.js.coffee +++ b/app/assets/javascripts/darkswarm/controllers/checkout_controller.js.coffee @@ -6,7 +6,7 @@ angular.module("Checkout").controller "CheckoutCtrl", ($scope, $rootScope, order # Our shipping_methods comes through as a hash like so: {id: requires_shipping_address} # Here we default to the first shipping method if none is selected $scope.order.shipping_method_id ||= Object.keys(order.shipping_methods)[0] - $scope.order.ship_address_same_as_billing ||= true + $scope.order.ship_address_same_as_billing = true if $scope.order.ship_address_same_as_billing == null $scope.require_ship_address = $scope.order.shipping_methods[$scope.order.shipping_method_id] $scope.shippingMethodChanged = -> @@ -16,3 +16,4 @@ angular.module("Checkout").controller "CheckoutCtrl", ($scope, $rootScope, order $scope.purchase = (event)-> event.preventDefault() checkout.submit() + diff --git a/app/views/shop/checkout/_order.rabl b/app/views/shop/checkout/_order.rabl index 237a782d85..fc18538afd 100644 --- a/app/views/shop/checkout/_order.rabl +++ b/app/views/shop/checkout/_order.rabl @@ -1,5 +1,8 @@ object current_order -attributes :id, :email, :shipping_method_id, :ship_address_same_as_billing +attributes :id, :email, :shipping_method_id +node :ship_address_same_as_billing do + current_order.ship_address_same_as_billing == "true" +end child current_order.bill_address => :bill_address do attributes :phone, :firstname, :lastname, :address1, :address2, :city, :country_id, :state_id, :zipcode diff --git a/spec/features/consumer/shopping/checkout_spec.rb b/spec/features/consumer/shopping/checkout_spec.rb index 16315be7a7..0fd76077d6 100644 --- a/spec/features/consumer/shopping/checkout_spec.rb +++ b/spec/features/consumer/shopping/checkout_spec.rb @@ -119,7 +119,7 @@ feature "As a consumer I want to check out my cart", js: true do fill_in "Customer E-Mail", with: "test@test.com" fill_in "Phone", with: "0468363090" fill_in "City", with: "Melbourne" - fill_in "Zip Code", with: "3066" + fill_in "Postcode", with: "3066" end click_button "Purchase" page.should have_content "Your order has been processed successfully" @@ -137,7 +137,7 @@ feature "As a consumer I want to check out my cart", js: true do fill_in "Customer E-Mail", with: "test@test.com" fill_in "Phone", with: "0468363090" fill_in "City", with: "Melbourne" - fill_in "Zip Code", with: "3066" + fill_in "Postcode", with: "3066" end check "Shipping address same as billing address?" click_button "Purchase" diff --git a/spec/features/consumer/shopping/shopping_spec.rb b/spec/features/consumer/shopping/shopping_spec.rb index 467ef2365f..d42470be26 100644 --- a/spec/features/consumer/shopping/shopping_spec.rb +++ b/spec/features/consumer/shopping/shopping_spec.rb @@ -134,13 +134,11 @@ feature "As a consumer I want to shop with a distributor", js: true do page.should_not have_selector("#variants_#{product.master.id}", visible: true) end - it "collapses variants by default" do - page.should_not have_text variant1.options_text + it "expands variants by default" do + page.should have_text variant1.options_text end it "expands variants" do - find(".expand").trigger "click" - page.should have_text variant1.options_text find(".collapse").trigger "click" page.should_not have_text variant1.options_text end @@ -161,7 +159,6 @@ feature "As a consumer I want to shop with a distributor", js: true do page.should_not have_selector 'tr.product > td', text: "from $33.00" # Page should have variant prices (with fee) - find(".expand").trigger 'click' page.should have_selector 'tr.variant > td.price', text: "$43.00" page.should have_selector 'tr.variant > td.price', text: "$53.00" @@ -223,7 +220,6 @@ feature "As a consumer I want to shop with a distributor", js: true do page.should_not have_content p3.name # It shows on demand variants - within(".product-#{p4.id}") { find(".expand", visible: true).trigger "click" } page.should have_content v3.options_text # It does not show variants that are neither on hand or on demand @@ -262,7 +258,6 @@ feature "As a consumer I want to shop with a distributor", js: true do let(:variant) { create(:variant, product: product, on_hand: 10 ) } before do build_and_select_order_cycle_with_variants - find(".expand").trigger "click" end it "should show group buy input" do @@ -289,7 +284,6 @@ feature "As a consumer I want to shop with a distributor", js: true do build_and_select_order_cycle_with_variants end it "should let us add products to our cart" do - find(".expand").trigger "click" fill_in "variants[#{variant.id}]", with: "1" first("form.custom > input.button.right").click current_path.should == "/cart"