From 573d479e08e5406ad19eefebb5065903841a8f02 Mon Sep 17 00:00:00 2001 From: Will Marshall Date: Fri, 9 May 2014 16:32:13 +1000 Subject: [PATCH] Fixing test regressions --- app/controllers/checkout_controller.rb | 1 + app/views/checkout/_form.html.haml | 11 +++++++---- app/views/checkout/_shipping.html.haml | 1 + spec/features/consumer/shopping/checkout_spec.rb | 6 ++++-- spec/support/request/checkout_workflow.rb | 11 +++++++++-- 5 files changed, 22 insertions(+), 8 deletions(-) diff --git a/app/controllers/checkout_controller.rb b/app/controllers/checkout_controller.rb index 43930818ca..daab4ec52b 100644 --- a/app/controllers/checkout_controller.rb +++ b/app/controllers/checkout_controller.rb @@ -11,6 +11,7 @@ class CheckoutController < Spree::CheckoutController end def update + if @order.update_attributes(params[:order]) fire_event('spree.checkout.update') while @order.state != "complete" diff --git a/app/views/checkout/_form.html.haml b/app/views/checkout/_form.html.haml index 74673342df..d7f27cf9a6 100644 --- a/app/views/checkout/_form.html.haml +++ b/app/views/checkout/_form.html.haml @@ -7,8 +7,8 @@ :javascript angular.module('Darkswarm').value('order', #{render "checkout/order"}) - -#%pre - -#{{ Order.order == order }} + %pre + {{ Order.order}} .small-12.columns %h3.text-center.pad-top @@ -19,5 +19,8 @@ = render partial: "checkout/billing", locals: {f: f} = render partial: "checkout/shipping", locals: {f: f} = render partial: "checkout/payment", locals: {f: f} - - %input.button.primary{type: :submit, value: "Place order now", "ng-show" => "checkout.$valid"} + %p + %input.button.primary{type: :submit, + value: "Place order now", + "ng-click" => "purchase($event)", + "ng-show" => "checkout.$valid"} diff --git a/app/views/checkout/_shipping.html.haml b/app/views/checkout/_shipping.html.haml index 29645c97d1..dfa69d43c5 100644 --- a/app/views/checkout/_shipping.html.haml +++ b/app/views/checkout/_shipping.html.haml @@ -30,6 +30,7 @@ -#= radio_button_tag "order[shipping_method_id]", ship_method.id, false, -#"ng-model" => "order.shipping_method_id" %input{type: :radio, value: ship_method.id, + required: true, "ng-model" => "order.shipping_method_id"} = ship_method.name diff --git a/spec/features/consumer/shopping/checkout_spec.rb b/spec/features/consumer/shopping/checkout_spec.rb index 9dc28d4a18..c24456b16a 100644 --- a/spec/features/consumer/shopping/checkout_spec.rb +++ b/spec/features/consumer/shopping/checkout_spec.rb @@ -35,6 +35,7 @@ feature "As a consumer I want to check out my cart", js: true do context "on the checkout page" do before do visit checkout_path + checkout_as_guest end it "shows all shipping methods, but doesn't show ship address when not needed" do @@ -62,6 +63,7 @@ feature "As a consumer I want to check out my cart", js: true do before do visit checkout_path + checkout_as_guest toggle_payment end @@ -93,7 +95,7 @@ feature "As a consumer I want to check out my cart", js: true do fill_in "Postcode", with: "3066" end - click_button "Purchase" + place_order page.should have_content "Your order has been processed successfully", wait: 10 ActionMailer::Base.deliveries.length.should == 1 email = ActionMailer::Base.deliveries.last @@ -123,7 +125,7 @@ feature "As a consumer I want to check out my cart", js: true do end toggle_shipping check "Shipping address same as billing address?" - click_button "Purchase" + place_order page.should have_content "Your order has been processed successfully", wait: 10 end end diff --git a/spec/support/request/checkout_workflow.rb b/spec/support/request/checkout_workflow.rb index 27102c10a5..ed513d2de9 100644 --- a/spec/support/request/checkout_workflow.rb +++ b/spec/support/request/checkout_workflow.rb @@ -3,10 +3,17 @@ module CheckoutWorkflow have_content "Customer details" end - def toggle_accordion(id) - find("##{id} dd > a").click + def checkout_as_guest + find("button", text: "Checkout as guest").trigger "click" end + def place_order + click_button "Place order now" + end + + def toggle_accordion(id) + find("##{id} dd a").trigger "click" + end def toggle_details toggle_accordion :details end