diff --git a/lib/active_shipping/location.rb b/lib/active_shipping/location.rb index 040903891..ebcf777b2 100644 --- a/lib/active_shipping/location.rb +++ b/lib/active_shipping/location.rb @@ -13,6 +13,7 @@ class Location address3: [:address3], phone: [:phone, :phone_number], fax: [:fax, :fax_number], + email: [:email], address_type: [:address_type], company_name: [:company, :company_name], }.freeze @@ -28,6 +29,7 @@ class Location :address3, :phone, :fax, + :email, :address_type, :company_name @@ -54,6 +56,7 @@ def initialize(options = {}) @address3 = options[:address3] @phone = options[:phone] @fax = options[:fax] + @email = options[:email] @company_name = options[:company_name] || options[:company] self.address_type = options[:address_type] @@ -122,6 +125,7 @@ def to_hash address3: address3, phone: phone, fax: fax, + email: email, address_type: address_type, company_name: company_name } @@ -142,6 +146,7 @@ def inspect string = prettyprint string << "\nPhone: #{@phone}" unless @phone.blank? string << "\nFax: #{@fax}" unless @fax.blank? + string << "\nEmail: #{@email}" unless @email.blank? string end diff --git a/test/test_helper.rb b/test/test_helper.rb index 9af918005..35f931cd0 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -116,7 +116,8 @@ def location_fixtures :address1 => '110 Laurier Avenue West', :postal_code => 'K1P 1J1', :phone => '1-613-580-2400', - :fax => '1-613-580-2495'), + :fax => '1-613-580-2495', + :email => 'bob.bobsen@gmail.com'), :ottawa_with_name => Location.new( :country => 'CA', :province => 'ON', :city => 'Ottawa', diff --git a/test/unit/location_test.rb b/test/unit/location_test.rb index 7b930a21c..f6bfb8de3 100644 --- a/test/unit/location_test.rb +++ b/test/unit/location_test.rb @@ -15,6 +15,7 @@ class LocationTest < ActiveSupport::TestCase address: '66 Gregory Ave.', phone: '515-555-1212', fax_number: 'none to speak of', + email: 'bob.bobsen@gmail.com', address_type: :commercial, name: "Bob Bobsen", } @@ -35,6 +36,7 @@ class LocationTest < ActiveSupport::TestCase assert_equal @attributes_hash[:address], location.address1 assert_equal @attributes_hash[:phone], location.phone assert_equal @attributes_hash[:fax_number], location.fax + assert_equal @attributes_hash[:email], location.email assert_equal @attributes_hash[:address_type].to_s, location.address_type assert_equal @attributes_hash[:name], location.name end @@ -62,6 +64,7 @@ def respond_to?(method) assert_equal @attributes_hash[:address], location.address1 assert_equal @attributes_hash[:phone], location.phone assert_equal @attributes_hash[:fax_number], location.fax + assert_equal @attributes_hash[:email], location.email assert_equal @attributes_hash[:address_type].to_s, location.address_type assert_equal @attributes_hash[:name], location.name end @@ -116,7 +119,7 @@ def province_code end test "#inspect returns a readable string" do - expected = "110 Laurier Avenue West\nOttawa, ON, K1P 1J1\nCanada\nPhone: 1-613-580-2400\nFax: 1-613-580-2495" + expected = "110 Laurier Avenue West\nOttawa, ON, K1P 1J1\nCanada\nPhone: 1-613-580-2400\nFax: 1-613-580-2495\nEmail: bob.bobsen@gmail.com" assert_equal expected, @location.inspect end @@ -165,7 +168,7 @@ def province_code end test "#to_hash has the expected attributes" do - expected = %w(address1 address2 address3 address_type city company_name country fax name phone postal_code province) + expected = %w(address1 address2 address3 address_type city company_name country email fax name phone postal_code province) assert_equal expected, @location.to_hash.stringify_keys.keys.sort end