From adb58bc059b5fdb8b80a1f5d2bf432739bf4b7d6 Mon Sep 17 00:00:00 2001 From: Will Marshall Date: Tue, 18 Feb 2014 15:07:00 +1100 Subject: [PATCH] Moving from @order to current_order to keep DRY --- app/controllers/shop/checkout_controller.rb | 7 +++++-- app/views/shop/checkout/_form.html.haml | 10 +++++----- app/views/shop/checkout/_summary.html.haml | 12 ++++++------ spec/features/consumer/shopping/checkout_spec.rb | 1 - 4 files changed, 16 insertions(+), 14 deletions(-) diff --git a/app/controllers/shop/checkout_controller.rb b/app/controllers/shop/checkout_controller.rb index d7b18c9324..e433e1acd4 100644 --- a/app/controllers/shop/checkout_controller.rb +++ b/app/controllers/shop/checkout_controller.rb @@ -6,8 +6,11 @@ class Shop::CheckoutController < BaseController before_filter :require_line_items def edit - @order = current_order - @order.bill_address ||= Spree::Address.new + current_order.bill_address ||= Spree::Address.new + end + + def update + end private diff --git a/app/views/shop/checkout/_form.html.haml b/app/views/shop/checkout/_form.html.haml index afae84fb99..6ac5a980b0 100644 --- a/app/views/shop/checkout/_form.html.haml +++ b/app/views/shop/checkout/_form.html.haml @@ -1,5 +1,5 @@ %checkout{"ng-controller" => "CheckoutCtrl"} - = form_for @order, url: shop_update_checkout_path, html: {name: "checkout", id: "checkout_form"} do |f| + = form_for current_order, url: shop_update_checkout_path, html: {name: "checkout", id: "checkout_form"} do |f| {{ checkout.$valid }} .large-12.columns %fieldset#details @@ -8,11 +8,11 @@ .large-6.columns = f.label :email, "Email Address" = f.text_field :email - = f.fields_for @order.bill_address do |ba| + = f.fields_for current_order.bill_address do |ba| .large-6.columns = ba.label :phone = ba.text_field :phone - = f.fields_for @order.bill_address do |ba| + = f.fields_for current_order.bill_address do |ba| .row .large-6.columns = ba.label :firstname @@ -23,7 +23,7 @@ %fieldset %legend Billing Address - = f.fields_for @order.bill_address do |ba| + = f.fields_for current_order.bill_address do |ba| .row .large-12.columns = ba.label :address1 @@ -57,7 +57,7 @@ "data-require-ship-address" => ship_method.require_ship_address = ship_method.name - = fields_for @order.ship_address do |sa| + = fields_for current_order.ship_address do |sa| #ship_address{"ng-show" => "require_ship_address"} .row .large-12.columns diff --git a/app/views/shop/checkout/_summary.html.haml b/app/views/shop/checkout/_summary.html.haml index 0f1ca388e0..edda8bc43a 100644 --- a/app/views/shop/checkout/_summary.html.haml +++ b/app/views/shop/checkout/_summary.html.haml @@ -1,21 +1,21 @@ %orderdetails{"ng-controller" => "CheckoutCtrl"} - = form_for @order, url: "#", html: {"ng-submit" => "purchase($event)"} do |f| + = form_for current_order, url: "#", html: {"ng-submit" => "purchase($event)"} do |f| %fieldset %legend Your Order %table %tr %th Cart subtotal - %td= @order.display_item_total + %td= current_order.display_item_total - - checkout_adjustments_for_summary(@order).each do |adjustment| + - checkout_adjustments_for_summary(current_order).each do |adjustment| %tr %th= adjustment.label %td= adjustment.display_amount.to_html %tr %th Cart total - %td= @order.display_total.to_html - - if @order.price_adjustment_totals.present? - - @order.price_adjustment_totals.each do |label, total| + %td= current_order.display_total.to_html + - if current_order.price_adjustment_totals.present? + - current_order.price_adjustment_totals.each do |label, total| %tr %th= label %td= total diff --git a/spec/features/consumer/shopping/checkout_spec.rb b/spec/features/consumer/shopping/checkout_spec.rb index 1d882be092..91fc4f2d7e 100644 --- a/spec/features/consumer/shopping/checkout_spec.rb +++ b/spec/features/consumer/shopping/checkout_spec.rb @@ -169,7 +169,6 @@ feature "As a consumer I want to check out my cart", js: true do end end - def select_distributor visit "/" click_link distributor.name