active_shipping 1.8.3 → 1.8.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/README.md +10 -10
- data/dev.yml +4 -0
- data/lib/active_shipping/carrier.rb +1 -1
- data/lib/active_shipping/carriers/ups.rb +2 -1
- data/lib/active_shipping/carriers/usps.rb +0 -2
- data/lib/active_shipping/rate_estimate.rb +6 -1
- data/lib/active_shipping/shipping_response.rb +1 -1
- data/lib/active_shipping/tracking_response.rb +2 -2
- data/lib/active_shipping/version.rb +1 -1
- data/test/unit/carrier_test.rb +11 -11
- data/test/unit/carriers/canada_post_pws_register_test.rb +3 -1
- data/test/unit/carriers/fedex_test.rb +15 -15
- data/test/unit/carriers/shipwire_test.rb +2 -2
- data/test/unit/carriers/ups_test.rb +8 -1
- data/test/unit/rate_estimate_test.rb +25 -3
- data/test/unit/shipment_event_test.rb +1 -1
- data/test/unit/tracking_response_test.rb +3 -3
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5712c0da451436687a6aa8d40beac5052f2a70ef
|
4
|
+
data.tar.gz: 428dfca820554e30e1878f4392f5382a19acf930
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a080e2b7592da6cf5650314ce14a91765a3ef3069a068fcbb48f809fcaa1a3be0d2b622544e3740e97153ff380ae944a9c590405ea66cfaab5238e0629b44889
|
7
|
+
data.tar.gz: 9ededa9fd2d52ddd0cd8d73185c79ddbf857eafd8ae8f728992d778c9f4b20b3cad4dd5d3586798b84d095df22ffa36b134f0391020106adf346791bd0b32a3e
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# ActiveShipping [![Build status](https://travis-ci.org/Shopify/active_shipping.svg?branch=master)](https://travis-ci.org/Shopify/active_shipping)
|
2
2
|
|
3
|
-
This library interfaces with the web services of various shipping carriers. The goal is to abstract the features that are most frequently used into a pleasant and consistent Ruby API
|
3
|
+
This library interfaces with the web services of various shipping carriers. The goal is to abstract the features that are most frequently used into a pleasant and consistent Ruby API:
|
4
4
|
|
5
5
|
- Finding shipping rates
|
6
6
|
- Registering shipments
|
@@ -116,15 +116,15 @@ After installing dependencies with `bundle install`, you can run the unit tests
|
|
116
116
|
|
117
117
|
## Development
|
118
118
|
|
119
|
-
Yes, please! Take a look at the tests and the implementation of the Carrier class to see how the basics work. At some point soon there will be a carrier template generator along the lines of the gateway generator included in Active Merchant, but carrier.rb outlines most of what's necessary. The other main classes that would be good to familiarize yourself with are Location, Package, and Response.
|
119
|
+
Yes, please! Take a look at the tests and the implementation of the Carrier class to see how the basics work. At some point soon there will be a carrier template generator along the lines of the gateway generator included in Active Merchant, but the [Carrier class](https://github.com/Shopify/active_shipping/blob/master/lib/active_shipping/carrier.rb) outlines most of what's necessary. The other main classes that would be good to familiarize yourself with are [Location](https://github.com/Shopify/active_shipping/blob/master/lib/active_shipping/location.rb), [Package](https://github.com/Shopify/active_shipping/blob/master/lib/active_shipping/package.rb), and [Response](https://github.com/Shopify/active_shipping/blob/master/lib/active_shipping/response.rb).
|
120
120
|
|
121
|
-
For the features you add, you should have both unit tests and remote tests. It's probably best to start with the remote tests, and then log those requests and responses and use them as the mocks for the unit tests. You can see how this works with the USPS tests right now:
|
121
|
+
For the features that you add, you should have both unit tests and remote tests. It's probably best to start with the remote tests, and then log those requests and responses and use them as the mocks for the unit tests. You can see how this works with the USPS tests right now:
|
122
122
|
|
123
|
-
https://github.com/Shopify/active_shipping/blob/master/test/remote/usps_test.rb
|
124
|
-
https://github.com/Shopify/active_shipping/blob/master/test/unit/carriers/usps_test.rb
|
125
|
-
https://github.com/Shopify/active_shipping/tree/master/test/fixtures/xml/usps
|
123
|
+
[https://github.com/Shopify/active_shipping/blob/master/test/remote/usps_test.rb](https://github.com/Shopify/active_shipping/blob/master/test/remote/usps_test.rb)
|
124
|
+
[https://github.com/Shopify/active_shipping/blob/master/test/unit/carriers/usps_test.rb](https://github.com/Shopify/active_shipping/blob/master/test/unit/carriers/usps_test.rb)
|
125
|
+
[https://github.com/Shopify/active_shipping/tree/master/test/fixtures/xml/usps](https://github.com/Shopify/active_shipping/tree/master/test/fixtures/xml/usps)
|
126
126
|
|
127
|
-
To log requests and responses, just set the `logger` on your
|
127
|
+
To log requests and responses, just set the `logger` on your Carrier class to some kind of `Logger` object:
|
128
128
|
|
129
129
|
```ruby
|
130
130
|
ActiveShipping::USPS.logger = Logger.new($stdout)
|
@@ -132,11 +132,11 @@ ActiveShipping::USPS.logger = Logger.new($stdout)
|
|
132
132
|
|
133
133
|
(This logging functionality is provided by the [`PostsData` module](https://github.com/Shopify/active_utils/blob/master/lib/active_utils/posts_data.rb) in the `active_utils` dependency.)
|
134
134
|
|
135
|
-
To debug API requests and your code you can run `rake console` to start a Pry session with `ActiveShipping` included
|
135
|
+
To debug API requests and your code, you can run `rake console` to start a Pry session with `ActiveShipping` included
|
136
136
|
and instances of the various carriers set up with your test credentials.
|
137
|
-
Look at the file `test/console.rb` to see the other goodies it provides.
|
137
|
+
Look at the file [`test/console.rb`](https://github.com/Shopify/active_shipping/blob/master/test/console.rb) to see the other goodies it provides.
|
138
138
|
|
139
|
-
After you've pushed your well-tested changes to your github fork, make a pull request and we'll take it from there! For more information, see CONTRIBUTING.md.
|
139
|
+
After you've pushed your well-tested changes to your github fork, make a pull request, and we'll take it from there! For more information, see [CONTRIBUTING.md](https://github.com/Shopify/active_shipping/blob/master/CONTRIBUTING.md).
|
140
140
|
|
141
141
|
## Legal Mumbo Jumbo
|
142
142
|
|
data/dev.yml
CHANGED
@@ -155,7 +155,7 @@ module ActiveShipping
|
|
155
155
|
@last_request = r
|
156
156
|
end
|
157
157
|
|
158
|
-
# Calculates a timestamp that corresponds a given number
|
158
|
+
# Calculates a timestamp that corresponds a given number of business days in the future
|
159
159
|
#
|
160
160
|
# @param days [Integer] The number of business days from now.
|
161
161
|
# @return [DateTime] A timestamp, the provided number of business days in the future.
|
@@ -1001,7 +1001,8 @@ module ActiveShipping
|
|
1001
1001
|
end
|
1002
1002
|
|
1003
1003
|
def commit(action, request, test = false)
|
1004
|
-
ssl_post("#{test ? TEST_URL : LIVE_URL}/#{RESOURCES[action]}", request)
|
1004
|
+
response = ssl_post("#{test ? TEST_URL : LIVE_URL}/#{RESOURCES[action]}", request)
|
1005
|
+
response.encode('utf-8', 'iso-8859-1')
|
1005
1006
|
end
|
1006
1007
|
|
1007
1008
|
def within_same_area?(origin, location)
|
@@ -118,8 +118,6 @@ module ActiveShipping
|
|
118
118
|
# Array of U.S. possessions according to USPS: https://www.usps.com/ship/official-abbreviations.htm
|
119
119
|
US_POSSESSIONS = %w(AS FM GU MH MP PW PR VI)
|
120
120
|
|
121
|
-
# TODO: figure out how USPS likes to say "Ivory Coast"
|
122
|
-
#
|
123
121
|
# Country names:
|
124
122
|
# http://pe.usps.gov/text/Imm/immctry.htm
|
125
123
|
COUNTRY_NAME_CONVERSIONS = {
|
@@ -75,6 +75,10 @@ module ActiveShipping
|
|
75
75
|
# Additional priced options bundled with the given rate estimate with price in cents
|
76
76
|
# @return [Array<{ code: String, price: Integer }>]
|
77
77
|
#
|
78
|
+
# @!attribute charge_items
|
79
|
+
# Breakdown of a shipping rate's price with amounts in cents.
|
80
|
+
# @return [Array<{ group: String, code: String, name: String, description: String, amount: Integer }>]
|
81
|
+
#
|
78
82
|
class RateEstimate
|
79
83
|
attr_accessor :origin, :destination, :package_rates,
|
80
84
|
:carrier, :service_name, :service_code, :description,
|
@@ -82,7 +86,7 @@ module ActiveShipping
|
|
82
86
|
:currency, :negotiated_rate, :insurance_price,
|
83
87
|
:estimate_reference, :expires_at, :pickup_time,
|
84
88
|
:compare_price, :phone_required, :delivery_category,
|
85
|
-
:shipment_options
|
89
|
+
:shipment_options, :charge_items
|
86
90
|
|
87
91
|
def initialize(origin, destination, carrier, service_name, options = {})
|
88
92
|
self.origin, self.destination, self.carrier, self.service_name = origin, destination, carrier, service_name
|
@@ -107,6 +111,7 @@ module ActiveShipping
|
|
107
111
|
self.insurance_price = options[:insurance_price]
|
108
112
|
self.delivery_category = options[:delivery_category]
|
109
113
|
self.shipment_options = options[:shipment_options] || []
|
114
|
+
self.charge_items = options[:charge_items] || []
|
110
115
|
end
|
111
116
|
|
112
117
|
# The total price of the shipments in cents.
|
@@ -11,7 +11,7 @@ module ActiveShipping
|
|
11
11
|
# @return [String]
|
12
12
|
#
|
13
13
|
# @!attribute tracking_number
|
14
|
-
# The tracking number of the shipments,
|
14
|
+
# The tracking number of the shipments, which can be shared with the customer and
|
15
15
|
# be used for {ActiveShipping::Carrier#find_tracking_info}.
|
16
16
|
# @return [String]
|
17
17
|
class ShippingResponse < Response
|
@@ -2,7 +2,7 @@ module ActiveShipping
|
|
2
2
|
|
3
3
|
# Represents the response to a {ActiveShipping::Carrier#find_tracking_info} call.
|
4
4
|
#
|
5
|
-
# @note Some carriers provide more information
|
5
|
+
# @note Some carriers provide more information than others, so not all attributes
|
6
6
|
# will be set, depending on what carrier you are using.
|
7
7
|
#
|
8
8
|
# @!attribute carrier
|
@@ -82,7 +82,7 @@ module ActiveShipping
|
|
82
82
|
@shipment_events.last
|
83
83
|
end
|
84
84
|
|
85
|
-
# Returns `true` if
|
85
|
+
# Returns `true` if the shipment has arrived at the destination.
|
86
86
|
# @return [Boolean]
|
87
87
|
def is_delivered?
|
88
88
|
@status == :delivered
|
data/test/unit/carrier_test.rb
CHANGED
@@ -58,8 +58,8 @@ class CarrierTest < Minitest::Test
|
|
58
58
|
end
|
59
59
|
|
60
60
|
def test_timestamp_from_business_day_returns_two_days_in_the_future
|
61
|
-
current = DateTime.
|
62
|
-
expected = DateTime.
|
61
|
+
current = DateTime.parse("Tue 19 Jul 2016")
|
62
|
+
expected = DateTime.parse("Thu 21 Jul 2016")
|
63
63
|
|
64
64
|
Timecop.freeze(current) do
|
65
65
|
assert_equal expected, @carrier.send(:timestamp_from_business_day, 2)
|
@@ -67,8 +67,8 @@ class CarrierTest < Minitest::Test
|
|
67
67
|
end
|
68
68
|
|
69
69
|
def test_timestamp_from_business_day_returns_two_days_in_the_future_over_a_weekend
|
70
|
-
current = DateTime.
|
71
|
-
expected = DateTime.
|
70
|
+
current = DateTime.parse("Fri 22 Jul 2016")
|
71
|
+
expected = DateTime.parse("Tue 26 Jul 2016")
|
72
72
|
|
73
73
|
Timecop.freeze(current) do
|
74
74
|
assert_equal expected, @carrier.send(:timestamp_from_business_day, 2)
|
@@ -76,8 +76,8 @@ class CarrierTest < Minitest::Test
|
|
76
76
|
end
|
77
77
|
|
78
78
|
def test_timestamp_from_business_day_returns_fifteen_days_in_the_future
|
79
|
-
current = DateTime.
|
80
|
-
expected = DateTime.
|
79
|
+
current = DateTime.parse("Wed 06 Jul 2016")
|
80
|
+
expected = DateTime.parse("Wed 27 Jul 2016") # includes 3 weekends
|
81
81
|
|
82
82
|
Timecop.freeze(current) do
|
83
83
|
assert_equal expected, @carrier.send(:timestamp_from_business_day, 15)
|
@@ -85,8 +85,8 @@ class CarrierTest < Minitest::Test
|
|
85
85
|
end
|
86
86
|
|
87
87
|
def test_timestamp_from_business_day_handles_saturday
|
88
|
-
current = DateTime.
|
89
|
-
expected = DateTime.
|
88
|
+
current = DateTime.parse("Sat 09 Jul 2016")
|
89
|
+
expected = DateTime.parse("Mon 11 Jul 2016")
|
90
90
|
|
91
91
|
Timecop.freeze(current) do
|
92
92
|
assert_equal expected, @carrier.send(:timestamp_from_business_day, 1)
|
@@ -94,8 +94,8 @@ class CarrierTest < Minitest::Test
|
|
94
94
|
end
|
95
95
|
|
96
96
|
def test_timestamp_from_business_day_handles_sunday
|
97
|
-
current = DateTime.
|
98
|
-
expected = DateTime.
|
97
|
+
current = DateTime.parse("Sun 10 Jul 2016")
|
98
|
+
expected = DateTime.parse("Mon 11 Jul 2016")
|
99
99
|
|
100
100
|
Timecop.freeze(current) do
|
101
101
|
assert_equal expected, @carrier.send(:timestamp_from_business_day, 1)
|
@@ -103,7 +103,7 @@ class CarrierTest < Minitest::Test
|
|
103
103
|
end
|
104
104
|
|
105
105
|
def test_timestamp_from_business_day_returns_datetime
|
106
|
-
Timecop.freeze(DateTime.
|
106
|
+
Timecop.freeze(DateTime.parse("Tue 19 Jul 2016")) do
|
107
107
|
assert_equal DateTime, @carrier.send(:timestamp_from_business_day, 1).class
|
108
108
|
end
|
109
109
|
end
|
@@ -37,9 +37,11 @@ class CanadaPostPwsRegisterTest < Minitest::Test
|
|
37
37
|
endpoint = @cp.endpoint + "ot/token"
|
38
38
|
response = xml_fixture('canadapost_pws/register_token_response')
|
39
39
|
@cp.expects(:ssl_post).with(endpoint, anything, anything).returns(response)
|
40
|
+
url = 'http://localhost:3000/cp-register/'
|
41
|
+
customer_id = "12345"
|
40
42
|
|
41
43
|
response = @cp.register_merchant
|
42
|
-
|
44
|
+
assert_equal "http://www.canadapost.ca/cpotools/apps/drc/merchant?return-url=#{customer_id}&token-id=#{response.token_id}&platform-id=#{url}", response.redirect_url(url, customer_id)
|
43
45
|
end
|
44
46
|
|
45
47
|
def test_retrieve_merchant_details
|
@@ -15,31 +15,31 @@ class FedExTest < Minitest::Test
|
|
15
15
|
end
|
16
16
|
|
17
17
|
def test_business_days
|
18
|
-
today = DateTime.
|
18
|
+
today = DateTime.parse("Tue 12 Mar 2013 00:00:00-0400")
|
19
19
|
|
20
20
|
Timecop.freeze(today) do
|
21
|
-
assert_equal DateTime.
|
22
|
-
assert_equal DateTime.
|
23
|
-
assert_equal DateTime.
|
24
|
-
assert_equal DateTime.
|
21
|
+
assert_equal DateTime.parse("Wed 13 Mar 2013 00:00:00-0400"), @carrier.send(:business_days_from, today, 1)
|
22
|
+
assert_equal DateTime.parse("Fri 15 Mar 2013 00:00:00-0400"), @carrier.send(:business_days_from, today, 3)
|
23
|
+
assert_equal DateTime.parse("Mon 18 Mar 2013 00:00:00-0400"), @carrier.send(:business_days_from, today, 4)
|
24
|
+
assert_equal DateTime.parse("Tue 19 Mar 2013 00:00:00-0400"), @carrier.send(:business_days_from, today, 5)
|
25
25
|
end
|
26
26
|
end
|
27
27
|
|
28
28
|
def test_home_delivery_business_days
|
29
|
-
today = DateTime.
|
29
|
+
today = DateTime.parse("Tue 12 Mar 2013 00:00:00-0400")
|
30
30
|
|
31
31
|
Timecop.freeze(today) do
|
32
|
-
assert_equal DateTime.
|
33
|
-
assert_equal DateTime.
|
34
|
-
assert_equal DateTime.
|
35
|
-
assert_equal DateTime.
|
32
|
+
assert_equal DateTime.parse("Wed 13 Mar 2013 00:00:00-0400"), @carrier.send(:business_days_from, today, 1, true)
|
33
|
+
assert_equal DateTime.parse("Fri 15 Mar 2013 00:00:00-0400"), @carrier.send(:business_days_from, today, 3, true)
|
34
|
+
assert_equal DateTime.parse("Sat 16 Mar 2013 00:00:00-0400"), @carrier.send(:business_days_from, today, 4, true)
|
35
|
+
assert_equal DateTime.parse("Tue 19 Mar 2013 00:00:00-0400"), @carrier.send(:business_days_from, today, 5, true)
|
36
36
|
end
|
37
37
|
end
|
38
38
|
|
39
39
|
def test_turn_around_time_default
|
40
40
|
mock_response = xml_fixture('fedex/ottawa_to_beverly_hills_rate_response').gsub('<v6:DeliveryTimestamp>2011-07-29</v6:DeliveryTimestamp>', '')
|
41
41
|
|
42
|
-
today =
|
42
|
+
today = Date.parse("Mon 11 Mar 2013")
|
43
43
|
|
44
44
|
Timecop.freeze(today) do
|
45
45
|
delivery_date = Date.today + 7.days # FIVE_DAYS in fixture response, plus weekend
|
@@ -260,7 +260,7 @@ class FedExTest < Minitest::Test
|
|
260
260
|
|
261
261
|
@carrier.expects(:commit).returns(mock_response)
|
262
262
|
|
263
|
-
today =
|
263
|
+
today = Date.parse("Fri 15 Mar 2013")
|
264
264
|
|
265
265
|
Timecop.freeze(today) do
|
266
266
|
rate_estimates = @carrier.find_rates( location_fixtures[:ottawa],
|
@@ -268,7 +268,7 @@ class FedExTest < Minitest::Test
|
|
268
268
|
package_fixtures.values_at(:book, :wii), :test => true)
|
269
269
|
|
270
270
|
# the above fixture will specify a transit time of 5 days, with 2 weekend days accounted for
|
271
|
-
delivery_date = Date.today +
|
271
|
+
delivery_date = Date.today + 5 + 2
|
272
272
|
assert_equal delivery_date, rate_estimates.rates[0].delivery_date
|
273
273
|
end
|
274
274
|
end
|
@@ -278,7 +278,7 @@ class FedExTest < Minitest::Test
|
|
278
278
|
|
279
279
|
@carrier.expects(:commit).returns(mock_response)
|
280
280
|
|
281
|
-
today =
|
281
|
+
today = Date.parse("Thursday 04 Jun 2015")
|
282
282
|
|
283
283
|
Timecop.freeze(today) do
|
284
284
|
rate_estimates = @carrier.find_rates( location_fixtures[:ottawa],
|
@@ -298,7 +298,7 @@ class FedExTest < Minitest::Test
|
|
298
298
|
|
299
299
|
@carrier.expects(:commit).returns(mock_response)
|
300
300
|
|
301
|
-
today =
|
301
|
+
today = Date.parse("Wed 03 Jun 2015") #Wednesday
|
302
302
|
|
303
303
|
Timecop.freeze(today) do
|
304
304
|
rate_estimates = @carrier.find_rates( location_fixtures[:ottawa],
|
@@ -23,7 +23,7 @@ class ShipwireTest < Minitest::Test
|
|
23
23
|
end
|
24
24
|
|
25
25
|
def test_successfully_get_international_rates
|
26
|
-
date = DateTime.
|
26
|
+
date = DateTime.parse("Mon 01 Aug 2011")
|
27
27
|
@carrier.expects(:ssl_post).returns(xml_fixture('shipwire/international_rates_response'))
|
28
28
|
|
29
29
|
Timecop.freeze(date) do
|
@@ -49,7 +49,7 @@ class ShipwireTest < Minitest::Test
|
|
49
49
|
end
|
50
50
|
|
51
51
|
def test_successfully_get_domestic_rates
|
52
|
-
date = DateTime.
|
52
|
+
date = DateTime.parse("Mon 01 Aug 2011")
|
53
53
|
@carrier.expects(:ssl_post).returns(xml_fixture('shipwire/rates_response'))
|
54
54
|
|
55
55
|
Timecop.freeze(date) do
|
@@ -179,6 +179,13 @@ class UPSTest < Minitest::Test
|
|
179
179
|
assert_equal "Failure: Package exceeds the maximum length constraint of 108 inches. Length is the longest side of a package.", e.message
|
180
180
|
end
|
181
181
|
|
182
|
+
def test_response_parsing_an_undecoded_character
|
183
|
+
unencoded_response = @tracking_response.gsub('NAPERVILLE', "N\xc4PERVILLE")
|
184
|
+
@carrier.stubs(:ssl_post).returns(unencoded_response)
|
185
|
+
response = @carrier.find_tracking_info('1Z5FX0076803466397')
|
186
|
+
assert_equal 'NÄPERVILLE', response.shipment_events.first.location.city
|
187
|
+
end
|
188
|
+
|
182
189
|
def test_response_parsing_an_unknown_error
|
183
190
|
mock_response = '<RatingServiceSelectionResponse><Response><ResponseStatusCode>0</ResponseStatusCode></Response></RatingServiceSelectionResponse>'
|
184
191
|
@carrier.expects(:commit).returns(mock_response)
|
@@ -527,7 +534,7 @@ class UPSTest < Minitest::Test
|
|
527
534
|
)
|
528
535
|
|
529
536
|
response.delivery_estimates.each do |delivery_estimate|
|
530
|
-
|
537
|
+
assert_equal delivery_estimate.service_code, UPS::DEFAULT_SERVICE_NAME_TO_CODE[delivery_estimate.service_name]
|
531
538
|
end
|
532
539
|
end
|
533
540
|
|
@@ -6,7 +6,7 @@ class RateEstimateTest < Minitest::Test
|
|
6
6
|
@destination = {city: "Beverly Hills", state: "CA", country: "United States", postal_code: "90210"}
|
7
7
|
@line_items = [Package.new(500, [2, 3, 4], description: "a box full of stuff", value: 2500)]
|
8
8
|
@carrier = CanadaPost.new(login: 'test')
|
9
|
-
@options = {currency: 'USD', delivery_range: [DateTime.
|
9
|
+
@options = {currency: 'USD', delivery_range: [DateTime.parse("Fri 01 Jul 2016"), DateTime.parse("Sun 03 Jul 2016")]}
|
10
10
|
|
11
11
|
@rate_estimate = RateEstimate.new(@origin, @destination, @carrier, @service_name, @options)
|
12
12
|
end
|
@@ -63,8 +63,30 @@ class RateEstimateTest < Minitest::Test
|
|
63
63
|
assert_equal "local_delivery", est.delivery_category
|
64
64
|
end
|
65
65
|
|
66
|
+
def test_charge_items_is_set
|
67
|
+
charge_items = [
|
68
|
+
{
|
69
|
+
group: "base_charge",
|
70
|
+
code: 'label',
|
71
|
+
name: "USPS Priority Mail label",
|
72
|
+
description: "USPS Priority Mail label to New York, NY, US",
|
73
|
+
amount: 14.64
|
74
|
+
},
|
75
|
+
{
|
76
|
+
group: "included_option",
|
77
|
+
code: 'tracking',
|
78
|
+
name: "Tracking",
|
79
|
+
description: "Free tracking",
|
80
|
+
amount: 0
|
81
|
+
}
|
82
|
+
]
|
83
|
+
est = RateEstimate.new(@origin, @destination, @carrier, @service_name, @options.merge(charge_items: charge_items))
|
84
|
+
|
85
|
+
assert_equal charge_items, est.charge_items
|
86
|
+
end
|
87
|
+
|
66
88
|
def test_delivery_date_pulls_from_delivery_range
|
67
|
-
assert_equal [DateTime.
|
68
|
-
assert_equal DateTime.
|
89
|
+
assert_equal [DateTime.parse("Fri 01 Jul 2016"), DateTime.parse("Sun 03 Jul 2016")], @rate_estimate.delivery_range
|
90
|
+
assert_equal DateTime.parse("Sun 03 Jul 2016"), @rate_estimate.delivery_date
|
69
91
|
end
|
70
92
|
end
|
@@ -4,7 +4,7 @@ class ShipmentEventTest < Minitest::Test
|
|
4
4
|
def test_equality
|
5
5
|
options1 = [
|
6
6
|
'ARRIVED AT UNIT',
|
7
|
-
DateTime.
|
7
|
+
DateTime.parse('Thu 12 May 2016 05:45:00'),
|
8
8
|
Location.new(city: 'SAN JOSE', state: 'CA', postal_code: '90001', country: 'US'),
|
9
9
|
'ARRIVED AT UNIT',
|
10
10
|
'07'
|
@@ -7,19 +7,19 @@ class TrackingResponseTest < Minitest::Test
|
|
7
7
|
status: 'DELIVERED',
|
8
8
|
status_code: 'I0',
|
9
9
|
status_description: 'DELIVERED',
|
10
|
-
actual_delivery_date: DateTime.
|
10
|
+
actual_delivery_date: DateTime.parse("Sat 14 May 2016 13:20:00"),
|
11
11
|
tracking_number: 'TRACKINGNUMBER1234ABC',
|
12
12
|
shipment_events: [
|
13
13
|
ShipmentEvent.new(
|
14
14
|
'DELIVERED',
|
15
|
-
DateTime.
|
15
|
+
DateTime.parse("Sat 14 May 2016 13:20:00"),
|
16
16
|
Location.new(city: 'LOS ANGELES', state: 'CA', postal_code: '90210', country: 'US'),
|
17
17
|
'DELIVERED',
|
18
18
|
'I0'
|
19
19
|
),
|
20
20
|
ShipmentEvent.new(
|
21
21
|
'ARRIVED AT UNIT',
|
22
|
-
DateTime.
|
22
|
+
DateTime.parse("Thu 12 May 2016 05:45:00"),
|
23
23
|
Location.new(city: 'SAN JOSE', state: 'CA', postal_code: '90001', country: 'US'),
|
24
24
|
'ARRIVED AT UNIT',
|
25
25
|
'07'
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: active_shipping
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.8.
|
4
|
+
version: 1.8.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- James MacAulay
|
@@ -11,7 +11,7 @@ authors:
|
|
11
11
|
autorequire:
|
12
12
|
bindir: bin
|
13
13
|
cert_chain: []
|
14
|
-
date: 2016-
|
14
|
+
date: 2016-11-17 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: quantified
|