Fixing typos and changing delivery address display in order confirmation email

This commit is contained in:
Rob Harrington
2014-12-12 11:59:17 +11:00
parent 086f69ccfb
commit 6a226e4f92
4 changed files with 81 additions and 44 deletions

View File

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

View File

@@ -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;"}

View File

@@ -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;"}

View File

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