Moving from @order to current_order to keep DRY

This commit is contained in:
Will Marshall
2014-02-18 15:07:00 +11:00
parent 6a861de1e1
commit adb58bc059
4 changed files with 16 additions and 14 deletions

View File

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

View File

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

View File

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

View File

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