From 6a226e4f92abe17287c904e11f9ed681ac15900d Mon Sep 17 00:00:00 2001 From: Rob Harrington Date: Fri, 12 Dec 2014 11:59:17 +1100 Subject: [PATCH] Fixing typos and changing delivery address display in order confirmation email --- app/models/spree/address_decorator.rb | 13 +++++-- .../confirm_email_for_customer.html.haml | 38 +++++++++++-------- .../confirm_email_for_shop.html.haml | 38 +++++++++++-------- spec/models/spree/addresses_spec.rb | 36 ++++++++++++++---- 4 files changed, 81 insertions(+), 44 deletions(-) diff --git a/app/models/spree/address_decorator.rb b/app/models/spree/address_decorator.rb index 8797a91599..03fa4da0cd 100644 --- a/app/models/spree/address_decorator.rb +++ b/app/models/spree/address_decorator.rb @@ -4,16 +4,21 @@ Spree::Address.class_eval do after_save :touch_enterprise - geocoded_by :full_address + geocoded_by :geocode_address delegate :name, :to => :state, :prefix => true, :allow_nil => true - def full_address - full_address = [address1, address2, zipcode, city, country.andand.name, state.andand.name] - filtered_address = full_address.select{ |field| !field.nil? && field != '' } + def geocode_address + geocode_address = [address1, address2, zipcode, city, country.andand.name, state.andand.name] + filtered_address = geocode_address.select{ |field| !field.nil? && field != '' } filtered_address.compact.join(', ') end + def full_address + full_address = [address1, address2, city, zipcode, state.andand.name] + filtered_address = full_address.select{ |field| !field.nil? && field != '' } + filtered_address.compact.join(', ') + end private diff --git a/app/views/spree/order_mailer/confirm_email_for_customer.html.haml b/app/views/spree/order_mailer/confirm_email_for_customer.html.haml index 49f23087ed..69629e256b 100644 --- a/app/views/spree/order_mailer/confirm_email_for_customer.html.haml +++ b/app/views/spree/order_mailer/confirm_email_for_customer.html.haml @@ -10,7 +10,7 @@ %p Thanks for shopping on %strong= "#{Spree::Config.site_name}." - Here are the details for you order from + Here are the details for your order from %strong= "#{@order.distributor.name}." %table.column{:align => "left"} %tr @@ -77,24 +77,28 @@ %p Your order will be delivered to: %br - #{@order.ship_address.to_s} + #{@order.ship_address.full_name} %br + #{@order.ship_address.full_address} + %br + #{@order.ship_address.phone} - if @order.shipping_method.andand.description + %br + %br #{@order.shipping_method.description.html_safe} - %br - %br - if @order.order_cycle.andand.pickup_time_for(@order.distributor) + %br + %br Delivery on: #{@order.order_cycle.pickup_time_for(@order.distributor)} - %br - %br - if @order.order_cycle.andand.pickup_instructions_for(@order.distributor) + %br + %br Other delivery information: #{@order.order_cycle.pickup_instructions_for(@order.distributor)} - %br - %br + %br - else / Collection details @@ -103,24 +107,26 @@ Collection details %p - if @order.shipping_method.andand.description + %br + %br = @order.shipping_method.description.html_safe - %br - %br - if @order.order_cycle.andand.pickup_time_for(@order.distributor) + %br + %br Ready for collection: #{@order.order_cycle.pickup_time_for(@order.distributor)} - %br - %br - if @order.order_cycle.andand.pickup_instructions_for(@order.distributor) + %br + %br Collection instructions: #{@order.order_cycle.pickup_instructions_for(@order.distributor)} - %br - %br - if @order.special_instructions.present? + %br + %br Notes: #{@order.special_instructions} - %br - %br + + %br -# Your order will be ready for collection on -# %strong{:style => "margin: 0;padding: 0;font-family: \"Helvetica Neue\", \"Helvetica\", Helvetica, Arial, sans-serif;"} diff --git a/app/views/spree/order_mailer/confirm_email_for_shop.html.haml b/app/views/spree/order_mailer/confirm_email_for_shop.html.haml index 49f23087ed..69629e256b 100644 --- a/app/views/spree/order_mailer/confirm_email_for_shop.html.haml +++ b/app/views/spree/order_mailer/confirm_email_for_shop.html.haml @@ -10,7 +10,7 @@ %p Thanks for shopping on %strong= "#{Spree::Config.site_name}." - Here are the details for you order from + Here are the details for your order from %strong= "#{@order.distributor.name}." %table.column{:align => "left"} %tr @@ -77,24 +77,28 @@ %p Your order will be delivered to: %br - #{@order.ship_address.to_s} + #{@order.ship_address.full_name} %br + #{@order.ship_address.full_address} + %br + #{@order.ship_address.phone} - if @order.shipping_method.andand.description + %br + %br #{@order.shipping_method.description.html_safe} - %br - %br - if @order.order_cycle.andand.pickup_time_for(@order.distributor) + %br + %br Delivery on: #{@order.order_cycle.pickup_time_for(@order.distributor)} - %br - %br - if @order.order_cycle.andand.pickup_instructions_for(@order.distributor) + %br + %br Other delivery information: #{@order.order_cycle.pickup_instructions_for(@order.distributor)} - %br - %br + %br - else / Collection details @@ -103,24 +107,26 @@ Collection details %p - if @order.shipping_method.andand.description + %br + %br = @order.shipping_method.description.html_safe - %br - %br - if @order.order_cycle.andand.pickup_time_for(@order.distributor) + %br + %br Ready for collection: #{@order.order_cycle.pickup_time_for(@order.distributor)} - %br - %br - if @order.order_cycle.andand.pickup_instructions_for(@order.distributor) + %br + %br Collection instructions: #{@order.order_cycle.pickup_instructions_for(@order.distributor)} - %br - %br - if @order.special_instructions.present? + %br + %br Notes: #{@order.special_instructions} - %br - %br + + %br -# Your order will be ready for collection on -# %strong{:style => "margin: 0;padding: 0;font-family: \"Helvetica Neue\", \"Helvetica\", Helvetica, Arial, sans-serif;"} diff --git a/spec/models/spree/addresses_spec.rb b/spec/models/spree/addresses_spec.rb index 6c6a88ba11..5fc9d442b6 100644 --- a/spec/models/spree/addresses_spec.rb +++ b/spec/models/spree/addresses_spec.rb @@ -9,23 +9,43 @@ describe Spree::Address do it { should delegate(:name).to(:state).with_prefix } end - describe "full address" do + describe "geocode address" do let(:address) { FactoryGirl.build(:address) } it "should include address1, address2, zipcode, city, state and country" do - address.full_address.should include(address.address1) - address.full_address.should include(address.address2) - address.full_address.should include(address.zipcode) - address.full_address.should include(address.city) - address.full_address.should include(address.state.name) - address.full_address.should include(address.country.name) + address.geocode_address.should include(address.address1) + address.geocode_address.should include(address.address2) + address.geocode_address.should include(address.zipcode) + address.geocode_address.should include(address.city) + address.geocode_address.should include(address.state.name) + address.geocode_address.should include(address.country.name) end it "should not include empty fields" do address.address2 = nil address.city = "" - address.full_address.split(',').length.should eql(4) + address.geocode_address.split(',').length.should eql(4) + end + end + + describe "full address" do + let(:address) { FactoryGirl.build(:address) } + + it "should include address1, address2, zipcode, city and state" do + address.full_address.should include(address.address1) + address.full_address.should include(address.address2) + address.full_address.should include(address.zipcode) + address.full_address.should include(address.city) + address.full_address.should include(address.state.name) + address.full_address.should_not include(address.country.name) + end + + it "should not include empty fields" do + address.address2 = nil + address.city = "" + + address.full_address.split(',').length.should eql(3) end end