active_shipping 0.1.4 → 0.9.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (73) hide show
  1. data/CHANGELOG +2 -0
  2. data/README.markdown +0 -3
  3. data/lib/active_merchant/common.rb +14 -0
  4. data/lib/{active_shipping/lib → active_merchant/common}/connection.rb +2 -0
  5. data/lib/{active_shipping/lib → active_merchant/common}/country.rb +0 -0
  6. data/lib/active_merchant/common/error.rb +26 -0
  7. data/lib/active_merchant/common/post_data.rb +24 -0
  8. data/lib/{active_shipping/lib → active_merchant/common}/posts_data.rb +0 -0
  9. data/lib/{active_shipping/lib → active_merchant/common}/requires_parameters.rb +0 -0
  10. data/lib/{active_shipping/lib → active_merchant/common}/utils.rb +0 -0
  11. data/lib/{active_shipping/lib → active_merchant/common}/validateable.rb +0 -0
  12. data/lib/active_shipping.rb +10 -22
  13. data/lib/active_shipping/shipping/base.rb +2 -1
  14. data/lib/active_shipping/shipping/carrier.rb +0 -5
  15. data/lib/active_shipping/shipping/carriers.rb +2 -1
  16. data/lib/active_shipping/shipping/carriers/fedex.rb +7 -191
  17. data/lib/active_shipping/shipping/carriers/kunaki.rb +165 -0
  18. data/lib/active_shipping/shipping/carriers/ups.rb +2 -1
  19. data/lib/active_shipping/shipping/carriers/usps.rb +0 -85
  20. data/lib/active_shipping/shipping/location.rb +1 -4
  21. data/lib/active_shipping/shipping/response.rb +1 -4
  22. data/lib/active_shipping/version.rb +3 -0
  23. data/lib/vendor/quantified/lib/quantified.rb +5 -3
  24. metadata +68 -102
  25. data/.gitignore +0 -8
  26. data/Rakefile +0 -51
  27. data/VERSION +0 -1
  28. data/active_shipping.gemspec +0 -152
  29. data/init.rb +0 -1
  30. data/lib/active_shipping/lib/error.rb +0 -4
  31. data/lib/active_shipping/lib/post_data.rb +0 -22
  32. data/lib/active_shipping/shipping/contact.rb +0 -18
  33. data/lib/active_shipping/shipping/label.rb +0 -31
  34. data/lib/active_shipping/shipping/location_response.rb +0 -14
  35. data/lib/active_shipping/shipping/party.rb +0 -15
  36. data/lib/active_shipping/shipping/return_label_response.rb +0 -14
  37. data/lib/active_shipping/shipping/return_shipment.rb +0 -14
  38. data/lib/active_shipping/shipping/shipment.rb +0 -73
  39. data/test/fixtures.example.yml +0 -13
  40. data/test/fixtures/xml/fedex/ottawa_to_beverly_hills_rate_request.xml +0 -67
  41. data/test/fixtures/xml/fedex/ottawa_to_beverly_hills_rate_response.xml +0 -213
  42. data/test/fixtures/xml/fedex/tracking_request.xml +0 -27
  43. data/test/fixtures/xml/fedex/tracking_response.xml +0 -153
  44. data/test/fixtures/xml/shipwire/international_rates_response.xml +0 -17
  45. data/test/fixtures/xml/shipwire/invalid_credentials_response.xml +0 -4
  46. data/test/fixtures/xml/shipwire/new_carrier_rate_response.xml +0 -18
  47. data/test/fixtures/xml/shipwire/no_rates_response.xml +0 -7
  48. data/test/fixtures/xml/shipwire/rates_response.xml +0 -36
  49. data/test/fixtures/xml/ups/example_tracking_response.xml +0 -53
  50. data/test/fixtures/xml/ups/shipment_from_tiger_direct.xml +0 -222
  51. data/test/fixtures/xml/ups/test_real_home_as_residential_destination_response.xml +0 -1
  52. data/test/fixtures/xml/usps/beverly_hills_to_ottawa_book_rate_response.xml +0 -85
  53. data/test/fixtures/xml/usps/beverly_hills_to_ottawa_book_wii_rate_response.xml +0 -168
  54. data/test/fixtures/xml/usps/beverly_hills_to_ottawa_wii_rate_response.xml +0 -85
  55. data/test/fixtures/xml/usps/example_tracking_response.xml +0 -104
  56. data/test/fixtures/xml/usps/multi_tracking_example.xml +0 -105
  57. data/test/party_factory.rb +0 -29
  58. data/test/remote/fedex_test.rb +0 -160
  59. data/test/remote/shipwire_test.rb +0 -88
  60. data/test/remote/ups_test.rb +0 -207
  61. data/test/remote/usps_test.rb +0 -184
  62. data/test/shipment_factory.rb +0 -27
  63. data/test/test_helper.rb +0 -171
  64. data/test/unit/base_test.rb +0 -18
  65. data/test/unit/carriers/fedex_test.rb +0 -78
  66. data/test/unit/carriers/shipwire_test.rb +0 -130
  67. data/test/unit/carriers/ups_test.rb +0 -81
  68. data/test/unit/carriers/usps_test.rb +0 -206
  69. data/test/unit/location_test.rb +0 -46
  70. data/test/unit/package_test.rb +0 -65
  71. data/test/unit/party_test.rb +0 -20
  72. data/test/unit/response_test.rb +0 -10
  73. data/test/unit/shipment_test.rb +0 -43
@@ -1,27 +0,0 @@
1
- class ShipmentFactory
2
- include ActiveMerchant::Shipping
3
-
4
- def self.build(carrier = :fedex)
5
- shipment = ReturnShipment.new
6
- if carrier == :fedex
7
- shipment.ship_at = Time.now
8
- shipment.service = 'FEDEX_GROUND'
9
- shipment.payment_type = 'RECIPIENT'
10
- shipment.packaging_type = FedEx::PackageTypes['your_packaging']
11
- shipment.recipient = PartyFactory.build(:fedex)
12
- jillians_boston = Location.new(
13
- :address1 => '145 Ipswitch Street',
14
- :city => 'Boston',
15
- :state => 'MA',
16
- :zip => '02215',
17
- :country => 'US'
18
- )
19
- shipment.shipper = PartyFactory.build(:fedex, :location => jillians_boston)
20
- shipment.total_weight_value = 10
21
- shipment.payment_type = 'SENDER'
22
- shipment.total_weight_units = 'LB'
23
- end
24
-
25
- shipment
26
- end
27
- end
data/test/test_helper.rb DELETED
@@ -1,171 +0,0 @@
1
- #!/usr/bin/env ruby
2
- $:.unshift(File.dirname(__FILE__) + '/../lib')
3
- $:.unshift(File.dirname(__FILE__))
4
-
5
- require 'test/unit'
6
- require 'active_shipping'
7
- require 'mocha'
8
-
9
- require 'shipment_factory'
10
- require 'party_factory'
11
-
12
- module Test
13
- module Unit
14
- class TestCase
15
- include ActiveMerchant::Shipping
16
-
17
- LOCAL_CREDENTIALS = ENV['HOME'] + '/.active_merchant/fixtures.yml' unless defined?(LOCAL_CREDENTIALS)
18
- DEFAULT_CREDENTIALS = File.dirname(__FILE__) + '/fixtures.yml' unless defined?(DEFAULT_CREDENTIALS)
19
-
20
- MODEL_FIXTURES = File.dirname(__FILE__) + '/fixtures/' unless defined?(MODEL_FIXTURES)
21
-
22
- def all_fixtures
23
- @@fixtures ||= load_fixtures
24
- end
25
-
26
- def fixtures(key)
27
- data = all_fixtures[key] || raise(StandardError, "No fixture data was found for '#{key}'")
28
-
29
- data.dup
30
- end
31
-
32
- def load_fixtures
33
- file = File.exists?(LOCAL_CREDENTIALS) ? LOCAL_CREDENTIALS : DEFAULT_CREDENTIALS
34
- yaml_data = YAML.load(File.read(file))
35
-
36
- model_fixtures = Dir.glob(File.join(MODEL_FIXTURES,'**','*.yml'))
37
- model_fixtures.each do |file|
38
- name = File.basename(file, '.yml')
39
- yaml_data[name] = YAML.load(File.read(file))
40
- end
41
-
42
- symbolize_keys(yaml_data)
43
-
44
- yaml_data
45
- end
46
-
47
- def xml_fixture(path) # where path is like 'usps/beverly_hills_to_ottawa_response'
48
- open(File.join(File.dirname(__FILE__),'fixtures','xml',"#{path}.xml")) {|f| f.read}
49
- end
50
-
51
- def symbolize_keys(hash)
52
- return unless hash.is_a?(Hash)
53
-
54
- hash.symbolize_keys!
55
- hash.each{|k,v| symbolize_keys(v)}
56
- end
57
-
58
- end
59
- end
60
- end
61
-
62
- module ActiveMerchant
63
- module Shipping
64
- module TestFixtures
65
-
66
- mattr_reader :packages, :locations
67
-
68
- @@packages = {
69
- :just_ounces => Package.new(16, nil, :units => :imperial),
70
- :just_grams => Package.new(1000, nil),
71
- :all_imperial => Package.new(16, [1,8,12], :units => :imperial),
72
- :all_metric => Package.new(1000, [2,20,40]),
73
- :book => Package.new(250, [14, 19, 2]),
74
- :wii => Package.new((7.5 * 16), [15, 10, 4.5], :units => :imperial, :value => 269.99, :currency => 'GBP'),
75
- :poster => Package.new(100, [93,10], :cylinder => true),
76
- :small_half_pound => Package.new(8, [1,1,1], :units => :imperial),
77
- :big_half_pound => Package.new((16 * 50), [24,24,36], :units => :imperial),
78
- :chocolate_stuff => Package.new(80, [2,6,12], :units => :imperial)
79
- }
80
-
81
- @@locations = {
82
- :bare_ottawa => Location.new(:country => 'CA', :postal_code => 'K1P 1J1'),
83
- :bare_beverly_hills => Location.new(:country => 'US', :zip => '90210'),
84
- :ottawa => Location.new( :country => 'CA',
85
- :province => 'ON',
86
- :city => 'Ottawa',
87
- :address1 => '110 Laurier Avenue West',
88
- :postal_code => 'K1P 1J1',
89
- :phone => '1-613-580-2400',
90
- :fax => '1-613-580-2495'),
91
- :beverly_hills => Location.new(
92
- :country => 'US',
93
- :state => 'CA',
94
- :city => 'Beverly Hills',
95
- :address1 => '455 N. Rexford Dr.',
96
- :address2 => '3rd Floor',
97
- :zip => '90210',
98
- :phone => '1-310-285-1013',
99
- :fax => '1-310-275-8159'),
100
- :real_home_as_commercial => Location.new(
101
- :country => 'US',
102
- :city => 'Tampa',
103
- :state => 'FL',
104
- :address1 => '7926 Woodvale Circle',
105
- :zip => '33615',
106
- :address_type => 'commercial'), # means that UPS will default to commercial if it doesn't know
107
- :fake_home_as_commercial => Location.new(
108
- :country => 'US',
109
- :state => 'FL',
110
- :address1 => '123 fake st.',
111
- :zip => '33615',
112
- :address_type => 'commercial'),
113
- :real_google_as_commercial => Location.new(
114
- :country => 'US',
115
- :city => 'Mountain View',
116
- :state => 'CA',
117
- :address1 => '1600 Amphitheatre Parkway',
118
- :zip => '94043',
119
- :address_type => 'commercial'),
120
- :real_google_as_residential => Location.new(
121
- :country => 'US',
122
- :city => 'Mountain View',
123
- :state => 'CA',
124
- :address1 => '1600 Amphitheatre Parkway',
125
- :zip => '94043',
126
- :address_type => 'residential'), # means that will default to residential if it doesn't know
127
- :fake_google_as_commercial => Location.new(
128
- :country => 'US',
129
- :city => 'Mountain View',
130
- :state => 'CA',
131
- :address1 => '123 bogusland dr.',
132
- :zip => '94043',
133
- :address_type => 'commercial'),
134
- :fake_google_as_residential => Location.new(
135
- :country => 'US',
136
- :city => 'Mountain View',
137
- :state => 'CA',
138
- :address1 => '123 bogusland dr.',
139
- :zip => '94043',
140
- :address_type => 'residential'), # means that will default to residential if it doesn't know
141
- :fake_home_as_residential => Location.new(
142
- :country => 'US',
143
- :state => 'FL',
144
- :address1 => '123 fake st.',
145
- :zip => '33615',
146
- :address_type => 'residential'),
147
- :real_home_as_residential => Location.new(
148
- :country => 'US',
149
- :city => 'Tampa',
150
- :state => 'FL',
151
- :address1 => '7926 Woodvale Circle',
152
- :zip => '33615',
153
- :address_type => 'residential'),
154
- :london => Location.new(
155
- :country => 'GB',
156
- :city => 'London',
157
- :address1 => '170 Westminster Bridge Rd.',
158
- :zip => 'SE1 7RW'),
159
- :new_york => Location.new(
160
- :country => 'US',
161
- :city => 'New York',
162
- :state => 'NY',
163
- :address1 => '780 3rd Avenue',
164
- :address2 => 'Suite 2601',
165
- :zip => '10017')
166
-
167
- }
168
-
169
- end
170
- end
171
- end
@@ -1,18 +0,0 @@
1
- require File.dirname(__FILE__) + '/../test_helper'
2
-
3
- class BaseTest < Test::Unit::TestCase
4
- include ActiveMerchant::Shipping
5
-
6
- def test_get_usps_by_string
7
- assert_equal USPS, Base.carrier('usps')
8
- assert_equal USPS, Base.carrier('USPS')
9
- end
10
-
11
- def test_get_usps_by_name
12
- assert_equal USPS, Base.carrier(:usps)
13
- end
14
-
15
- def test_get_unknown_carrier
16
- assert_raise(NameError){ Base.carrier(:polar_north) }
17
- end
18
- end
@@ -1,78 +0,0 @@
1
- require File.dirname(__FILE__) + '/../../test_helper'
2
-
3
- class FedExTest < Test::Unit::TestCase
4
- def setup
5
- @packages = TestFixtures.packages
6
- @locations = TestFixtures.locations
7
- @carrier = FedEx.new(:key => '1111', :password => '2222', :account => '3333', :login => '4444')
8
- end
9
-
10
- def test_initialize_options_requirements
11
- assert_raises ArgumentError do FedEx.new end
12
- assert_raises ArgumentError do FedEx.new(:login => '999999999') end
13
- assert_raises ArgumentError do FedEx.new(:password => '7777777') end
14
- assert_nothing_raised { FedEx.new(:key => '999999999', :password => '7777777', :account => '123', :login => '123')}
15
- end
16
-
17
- # def test_no_rates_response
18
- # @carrier.expects(:commit).returns(xml_fixture('fedex/empty_response'))
19
- #
20
- # response = @carrier.find_rates(
21
- # @locations[:ottawa],
22
- # @locations[:beverly_hills],
23
- # @packages.values_at(:book, :wii)
24
- # )
25
- # assert_equal "WARNING - 556: There are no valid services available. ", response.message
26
- # end
27
-
28
- def test_find_tracking_info_should_return_a_tracking_response
29
- @carrier.expects(:commit).returns(xml_fixture('fedex/tracking_response'))
30
- assert_instance_of ActiveMerchant::Shipping::TrackingResponse, @carrier.find_tracking_info('077973360403984', :test => true)
31
- end
32
-
33
- def test_find_tracking_info_should_parse_response_into_correct_number_of_shipment_events
34
- @carrier.expects(:commit).returns(xml_fixture('fedex/tracking_response'))
35
- response = @carrier.find_tracking_info('077973360403984', :test => true)
36
- assert_equal 7, response.shipment_events.size
37
- end
38
-
39
- def test_find_tracking_info_should_return_shipment_events_in_ascending_chronological_order
40
- @carrier.expects(:commit).returns(xml_fixture('fedex/tracking_response'))
41
- response = @carrier.find_tracking_info('077973360403984', :test => true)
42
- assert_equal response.shipment_events.map(&:time).sort, response.shipment_events.map(&:time)
43
- end
44
-
45
- def test_building_request_and_parsing_response
46
- expected_request = xml_fixture('fedex/ottawa_to_beverly_hills_rate_request')
47
- mock_response = xml_fixture('fedex/ottawa_to_beverly_hills_rate_response')
48
- Time.any_instance.expects(:to_xml_value).returns("2009-07-20T12:01:55-04:00")
49
-
50
- @carrier.expects(:commit).with {|request, test_mode| Hash.from_xml(request) == Hash.from_xml(expected_request) && test_mode}.returns(mock_response)
51
- response = @carrier.find_rates( @locations[:ottawa],
52
- @locations[:beverly_hills],
53
- @packages.values_at(:book, :wii), :test => true)
54
- assert_equal ["FedEx Ground"], response.rates.map(&:service_name)
55
- assert_equal [3836], response.rates.map(&:price)
56
-
57
- assert response.success?, response.message
58
- assert_instance_of Hash, response.params
59
- assert_instance_of String, response.xml
60
- assert_instance_of Array, response.rates
61
- assert_not_equal [], response.rates
62
-
63
- rate = response.rates.first
64
- assert_equal 'FedEx', rate.carrier
65
- assert_equal 'CAD', rate.currency
66
- assert_instance_of Fixnum, rate.total_price
67
- assert_instance_of Fixnum, rate.price
68
- assert_instance_of String, rate.service_name
69
- assert_instance_of String, rate.service_code
70
- assert_instance_of Array, rate.package_rates
71
- assert_equal @packages.values_at(:book, :wii), rate.packages
72
-
73
- package_rate = rate.package_rates.first
74
- assert_instance_of Hash, package_rate
75
- assert_instance_of Package, package_rate[:package]
76
- assert_nil package_rate[:rate]
77
- end
78
- end
@@ -1,130 +0,0 @@
1
- require File.dirname(__FILE__) + '/../../test_helper'
2
-
3
- class ShipwireTest < Test::Unit::TestCase
4
-
5
- def setup
6
- @packages = TestFixtures.packages
7
- @locations = TestFixtures.locations
8
- @carrier = Shipwire.new(:login => 'l', :password => 'p')
9
- @items = [ { :sku => 'AF0001', :quantity => 1 }, { :sku => 'AF0002', :quantity => 2 } ]
10
- end
11
-
12
- def test_invalid_credentials
13
- @carrier.expects(:ssl_post).returns(xml_fixture('shipwire/invalid_credentials_response'))
14
-
15
- begin
16
- @carrier.find_rates(
17
- @locations[:ottawa],
18
- @locations[:beverly_hills],
19
- @packages.values_at(:book, :wii),
20
- :order_id => '#1000',
21
- :items => @items
22
- )
23
- rescue ResponseError => e
24
- assert_equal "Could not verify e-mail/password combination", e.message
25
- end
26
- end
27
-
28
- def test_response_with_no_rates_is_unsuccessful
29
- @carrier.expects(:ssl_post).returns(xml_fixture('shipwire/no_rates_response'))
30
-
31
- assert_raises(ResponseError) do
32
- response = @carrier.find_rates(
33
- @locations[:ottawa],
34
- @locations[:beverly_hills],
35
- @packages.values_at(:book, :wii),
36
- :order_id => '#1000',
37
- :items => @items
38
- )
39
- end
40
- end
41
-
42
- def test_successfully_get_international_rates
43
- @carrier.expects(:ssl_post).returns(xml_fixture('shipwire/international_rates_response'))
44
-
45
- response = @carrier.find_rates(
46
- @locations[:ottawa],
47
- @locations[:london],
48
- @packages.values_at(:book, :wii),
49
- :order_id => '#1000',
50
- :items => @items
51
- )
52
-
53
- assert response.success?
54
-
55
- assert_equal 1, response.rates.size
56
-
57
- assert international = response.rates.first
58
- assert_equal "INTL", international.service_code
59
- assert_equal "UPS", international.carrier
60
- assert_equal "UPS Standard", international.service_name
61
- assert_equal 2806, international.total_price
62
- end
63
-
64
- def test_successfully_get_domestic_rates
65
- @carrier.expects(:ssl_post).returns(xml_fixture('shipwire/rates_response'))
66
-
67
- response = @carrier.find_rates(
68
- @locations[:ottawa],
69
- @locations[:beverly_hills],
70
- @packages.values_at(:book, :wii),
71
- :order_id => '#1000',
72
- :items => @items
73
- )
74
-
75
- assert response.success?
76
-
77
- assert_equal 3, response.rates.size
78
-
79
- assert ground = response.rates.find{|r| r.service_code == "GD" }
80
- assert_equal "UPS", ground.carrier
81
- assert_equal "UPS Ground", ground.service_name
82
- assert_equal 773, ground.total_price
83
-
84
- assert two_day = response.rates.find{|r| r.service_code == "2D" }
85
- assert_equal "UPS", two_day.carrier
86
- assert_equal "UPS Second Day Air", two_day.service_name
87
- assert_equal 1364, two_day.total_price
88
-
89
- assert one_day = response.rates.find{|r| r.service_code == "1D" }
90
- assert_equal "USPS", one_day.carrier
91
- assert_equal "USPS Express Mail", one_day.service_name
92
- assert_equal 2525, one_day.total_price
93
- end
94
-
95
- def test_gracefully_handle_new_carrier
96
- @carrier.expects(:ssl_post).returns(xml_fixture('shipwire/new_carrier_rate_response'))
97
-
98
- response = @carrier.find_rates(
99
- @locations[:ottawa],
100
- @locations[:beverly_hills],
101
- @packages.values_at(:book, :wii),
102
- :order_id => '#1000',
103
- :items => @items
104
- )
105
- assert response.success?
106
- assert_equal 1, response.rates.size
107
- assert ground = response.rates.first
108
- assert_equal "FESCO", ground.carrier
109
- end
110
-
111
- def test_find_rates_requires_items_option
112
- assert_raises(ArgumentError) do
113
- @carrier.find_rates(
114
- @locations[:ottawa],
115
- @locations[:beverly_hills],
116
- @packages.values_at(:book, :wii)
117
- )
118
- end
119
- end
120
-
121
- def test_validate_credentials_with_valid_credentials
122
- @carrier.expects(:ssl_post).returns(xml_fixture('shipwire/no_rates_response'))
123
- assert @carrier.valid_credentials?
124
- end
125
-
126
- def test_validate_credentials_with_invalid_credentials
127
- @carrier.expects(:ssl_post).returns(xml_fixture('shipwire/invalid_credentials_response'))
128
- assert !@carrier.valid_credentials?
129
- end
130
- end
@@ -1,81 +0,0 @@
1
- require File.dirname(__FILE__) + '/../../test_helper'
2
-
3
- class UPSTest < Test::Unit::TestCase
4
-
5
- def setup
6
- @packages = TestFixtures.packages
7
- @locations = TestFixtures.locations
8
- @carrier = UPS.new(
9
- :key => 'key',
10
- :login => 'login',
11
- :password => 'password'
12
- )
13
- @tracking_response = xml_fixture('ups/shipment_from_tiger_direct')
14
- end
15
-
16
- def test_initialize_options_requirements
17
- assert_raises(ArgumentError) { UPS.new }
18
- assert_raises(ArgumentError) { UPS.new(:login => 'blah', :password => 'bloo') }
19
- assert_raises(ArgumentError) { UPS.new(:login => 'blah', :key => 'kee') }
20
- assert_raises(ArgumentError) { UPS.new(:password => 'bloo', :key => 'kee') }
21
- assert_nothing_raised { UPS.new(:login => 'blah', :password => 'bloo', :key => 'kee') }
22
- end
23
-
24
- def test_find_tracking_info_should_return_a_tracking_response
25
- @carrier.expects(:commit).returns(@tracking_response)
26
- assert_equal 'ActiveMerchant::Shipping::TrackingResponse', @carrier.find_tracking_info('1Z5FX0076803466397').class.name
27
- end
28
-
29
- def test_find_tracking_info_should_parse_response_into_correct_number_of_shipment_events
30
- @carrier.expects(:commit).returns(@tracking_response)
31
- response = @carrier.find_tracking_info('1Z5FX0076803466397')
32
- assert_equal 8, response.shipment_events.size
33
- end
34
-
35
- def test_find_tracking_info_should_return_shipment_events_in_ascending_chronological_order
36
- @carrier.expects(:commit).returns(@tracking_response)
37
- response = @carrier.find_tracking_info('1Z5FX0076803466397')
38
- assert_equal response.shipment_events.map(&:time).sort, response.shipment_events.map(&:time)
39
- end
40
-
41
- def test_find_tracking_info_should_have_correct_names_for_shipment_events
42
- @carrier.expects(:commit).returns(@tracking_response)
43
- response = @carrier.find_tracking_info('1Z5FX0076803466397')
44
- assert_equal [ "BILLING INFORMATION RECEIVED",
45
- "IMPORT SCAN",
46
- "LOCATION SCAN",
47
- "LOCATION SCAN",
48
- "DEPARTURE SCAN",
49
- "ARRIVAL SCAN",
50
- "OUT FOR DELIVERY",
51
- "DELIVERED" ], response.shipment_events.map(&:name)
52
- end
53
-
54
- def test_add_origin_and_destination_data_to_shipment_events_where_appropriate
55
- @carrier.expects(:commit).returns(@tracking_response)
56
- response = @carrier.find_tracking_info('1Z5FX0076803466397')
57
- assert_equal '175 AMBASSADOR', response.shipment_events.first.location.address1
58
- assert_equal 'K1N5X8', response.shipment_events.last.location.postal_code
59
- end
60
-
61
- def test_response_parsing
62
- mock_response = xml_fixture('ups/test_real_home_as_residential_destination_response')
63
- @carrier.expects(:commit).returns(mock_response)
64
- response = @carrier.find_rates( @locations[:beverly_hills],
65
- @locations[:real_home_as_residential],
66
- @packages.values_at(:chocolate_stuff))
67
- assert_equal [ "UPS Ground",
68
- "UPS Three-Day Select",
69
- "UPS Second Day Air",
70
- "UPS Next Day Air Saver",
71
- "UPS Next Day Air Early A.M.",
72
- "UPS Next Day Air"], response.rates.map(&:service_name)
73
- assert_equal [992, 2191, 3007, 5509, 9401, 6124], response.rates.map(&:price)
74
- end
75
-
76
- def test_maximum_weight
77
- assert Package.new(150 * 16, [5,5,5], :units => :imperial).mass == @carrier.maximum_weight
78
- assert Package.new((150 * 16) + 0.01, [5,5,5], :units => :imperial).mass > @carrier.maximum_weight
79
- assert Package.new((150 * 16) - 0.01, [5,5,5], :units => :imperial).mass < @carrier.maximum_weight
80
- end
81
- end