active_shipping 1.14.2 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +3 -25
- data/CHANGELOG.md +5 -0
- data/CONTRIBUTING.md +2 -0
- data/README.md +2 -8
- data/active_shipping.gemspec +9 -3
- data/gemfiles/activesupport42.gemfile +0 -1
- data/lib/active_shipping.rb +1 -1
- data/lib/active_shipping/carrier.rb +2 -4
- data/lib/active_shipping/carriers/australia_post.rb +2 -4
- data/lib/active_shipping/carriers/canada_post.rb +1 -1
- data/lib/active_shipping/carriers/canada_post_pws.rb +33 -37
- data/lib/active_shipping/carriers/correios.rb +0 -2
- data/lib/active_shipping/carriers/new_zealand_post.rb +0 -2
- data/lib/active_shipping/carriers/ups.rb +0 -2
- data/lib/active_shipping/carriers/usps.rb +1 -3
- data/lib/active_shipping/external_return_label_request.rb +0 -4
- data/lib/active_shipping/location.rb +65 -52
- data/lib/active_shipping/package.rb +17 -21
- data/lib/active_shipping/package_item.rb +8 -20
- data/lib/active_shipping/rate_estimate.rb +1 -1
- data/lib/active_shipping/version.rb +1 -1
- data/test/fixtures/xml/canadapost/example_request.xml +3 -3
- data/test/helpers/holiday_helpers.rb +54 -0
- data/test/remote/australia_post_test.rb +1 -1
- data/test/remote/canada_post_pws_platform_test.rb +1 -3
- data/test/remote/canada_post_pws_test.rb +1 -1
- data/test/remote/canada_post_test.rb +1 -1
- data/test/remote/correios_test.rb +1 -2
- data/test/remote/fedex_test.rb +8 -8
- data/test/remote/kunaki_test.rb +1 -1
- data/test/remote/new_zealand_post_test.rb +1 -1
- data/test/remote/shipwire_test.rb +1 -1
- data/test/remote/stamps_test.rb +7 -7
- data/test/remote/ups_surepost_test.rb +1 -1
- data/test/remote/ups_test.rb +13 -11
- data/test/remote/usps_returns_test.rb +1 -1
- data/test/remote/usps_test.rb +5 -5
- data/test/test_helper.rb +16 -6
- data/test/unit/carrier_test.rb +25 -25
- data/test/unit/carriers/australia_post_test.rb +5 -5
- data/test/unit/carriers/benchmark_test.rb +1 -1
- data/test/unit/carriers/canada_post_pws_rating_test.rb +1 -15
- data/test/unit/carriers/canada_post_pws_register_test.rb +1 -15
- data/test/unit/carriers/canada_post_pws_shipping_test.rb +1 -13
- data/test/unit/carriers/canada_post_pws_test.rb +4 -4
- data/test/unit/carriers/canada_post_pws_tracking_test.rb +1 -1
- data/test/unit/carriers/canada_post_test.rb +9 -9
- data/test/unit/carriers/correios_test.rb +1 -2
- data/test/unit/carriers/fedex_test.rb +5 -5
- data/test/unit/carriers/kunaki_test.rb +1 -1
- data/test/unit/carriers/new_zealand_post_test.rb +9 -10
- data/test/unit/carriers/shipwire_test.rb +1 -1
- data/test/unit/carriers/stamps_test.rb +1 -1
- data/test/unit/carriers/ups_test.rb +1 -1
- data/test/unit/carriers/usps_returns_test.rb +1 -1
- data/test/unit/carriers/usps_test.rb +1 -1
- data/test/unit/carriers_test.rb +4 -5
- data/test/unit/external_return_label_request_test.rb +129 -83
- data/test/unit/location_test.rb +187 -91
- data/test/unit/package_item_test.rb +42 -47
- data/test/unit/package_test.rb +76 -75
- data/test/unit/rate_estimate_test.rb +16 -20
- data/test/unit/response_test.rb +28 -9
- data/test/unit/shipment_event_test.rb +1 -1
- data/test/unit/shipment_packer_test.rb +31 -31
- data/test/unit/tracking_response_test.rb +1 -1
- metadata +71 -23
- data/gemfiles/activesupport32.gemfile +0 -7
- data/gemfiles/activesupport32_nokogiri_17.gemfile +0 -7
- data/gemfiles/activesupport40.gemfile +0 -6
- data/gemfiles/activesupport40_nokogiri_17.gemfile +0 -6
- data/gemfiles/activesupport41.gemfile +0 -6
- data/gemfiles/activesupport41_nokogiri_17.gemfile +0 -6
- data/gemfiles/activesupport42_nokogiri_17.gemfile +0 -6
- data/test/fixtures/xml/canadapost_pws/merchant_details_response_no_contract_number.xml +0 -7
- data/test/fixtures/xml/canadapost_pws/service_options_response_priority_worldwide.xml +0 -41
data/test/remote/ups_test.rb
CHANGED
@@ -1,8 +1,9 @@
|
|
1
1
|
require 'test_helper'
|
2
2
|
|
3
|
-
class RemoteUPSTest <
|
3
|
+
class RemoteUPSTest < ActiveSupport::TestCase
|
4
4
|
include ActiveShipping::Test::Credentials
|
5
5
|
include ActiveShipping::Test::Fixtures
|
6
|
+
include HolidayHelpers
|
6
7
|
|
7
8
|
def setup
|
8
9
|
@options = credentials(:ups).merge(:test => true)
|
@@ -79,12 +80,12 @@ class RemoteUPSTest < Minitest::Test
|
|
79
80
|
assert_equal 'UPS', rate.carrier
|
80
81
|
assert_equal 'CAD', rate.currency
|
81
82
|
if @options[:origin_account]
|
82
|
-
|
83
|
+
assert_kind_of Integer, rate.negotiated_rate
|
83
84
|
else
|
84
85
|
assert_equal rate.negotiated_rate, 0
|
85
86
|
end
|
86
|
-
|
87
|
-
|
87
|
+
assert_kind_of Integer, rate.total_price
|
88
|
+
assert_kind_of Integer, rate.price
|
88
89
|
assert_instance_of String, rate.service_name
|
89
90
|
assert_instance_of String, rate.service_code
|
90
91
|
assert_instance_of Array, rate.package_rates
|
@@ -312,7 +313,7 @@ class RemoteUPSTest < Minitest::Test
|
|
312
313
|
assert response.success?
|
313
314
|
refute_empty response.delivery_estimates
|
314
315
|
ground_delivery_estimate = response.delivery_estimates.select {|de| de.service_name == "UPS Ground"}.first
|
315
|
-
assert_equal 1.business_days.after(today), ground_delivery_estimate.date
|
316
|
+
with_holidays(:ups) { assert_equal 1.business_days.after(today), ground_delivery_estimate.date }
|
316
317
|
end
|
317
318
|
|
318
319
|
def test_delivery_date_estimates_within_zip_with_no_value
|
@@ -331,7 +332,7 @@ class RemoteUPSTest < Minitest::Test
|
|
331
332
|
assert response.success?
|
332
333
|
refute_empty response.delivery_estimates
|
333
334
|
ground_delivery_estimate = response.delivery_estimates.select {|de| de.service_name == "UPS Ground"}.first
|
334
|
-
assert_equal 1.business_days.after(today), ground_delivery_estimate.date
|
335
|
+
with_holidays(:ups) { assert_equal 1.business_days.after(today), ground_delivery_estimate.date }
|
335
336
|
end
|
336
337
|
|
337
338
|
def test_delivery_date_estimates_across_zips
|
@@ -350,9 +351,11 @@ class RemoteUPSTest < Minitest::Test
|
|
350
351
|
assert response.success?
|
351
352
|
refute_empty response.delivery_estimates
|
352
353
|
ground_delivery_estimate = response.delivery_estimates.select {|de| de.service_name == "UPS Ground"}.first
|
353
|
-
|
354
|
-
|
355
|
-
|
354
|
+
with_holidays(:ups) do
|
355
|
+
assert_equal 3.business_days.after(today), ground_delivery_estimate.date
|
356
|
+
next_day_delivery_estimate = response.delivery_estimates.select {|de| de.service_name == "UPS Next Day Air"}.first
|
357
|
+
assert_equal 1.business_days.after(today), next_day_delivery_estimate.date
|
358
|
+
end
|
356
359
|
end
|
357
360
|
|
358
361
|
def test_rate_with_single_service
|
@@ -387,8 +390,7 @@ class RemoteUPSTest < Minitest::Test
|
|
387
390
|
assert response.success?
|
388
391
|
refute_empty response.delivery_estimates
|
389
392
|
ww_express_estimate = response.delivery_estimates.select {|de| de.service_name == "UPS Worldwide Express"}.first
|
390
|
-
|
391
|
-
assert_equal expected_estimate, ww_express_estimate.date
|
393
|
+
with_holidays(:ups) { assert_equal 1.business_days.after(today), ww_express_estimate.date }
|
392
394
|
end
|
393
395
|
|
394
396
|
def test_void_shipment
|
data/test/remote/usps_test.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
require 'test_helper'
|
2
2
|
|
3
|
-
class RemoteUSPSTest <
|
3
|
+
class RemoteUSPSTest < ActiveSupport::TestCase
|
4
4
|
include ActiveShipping::Test::Credentials
|
5
5
|
include ActiveShipping::Test::Fixtures
|
6
6
|
|
@@ -76,8 +76,8 @@ class RemoteUSPSTest < Minitest::Test
|
|
76
76
|
rate = response.rates.first
|
77
77
|
assert_equal 'USPS', rate.carrier
|
78
78
|
assert_equal 'USD', rate.currency
|
79
|
-
|
80
|
-
|
79
|
+
assert_kind_of Integer, rate.total_price
|
80
|
+
assert_kind_of Integer, rate.price
|
81
81
|
assert_instance_of String, rate.service_name
|
82
82
|
assert_instance_of String, rate.service_code
|
83
83
|
assert_instance_of Array, rate.package_rates
|
@@ -109,8 +109,8 @@ class RemoteUSPSTest < Minitest::Test
|
|
109
109
|
rate = response.rates.first
|
110
110
|
assert_equal 'USPS', rate.carrier
|
111
111
|
assert_equal 'USD', rate.currency
|
112
|
-
|
113
|
-
|
112
|
+
assert_kind_of Integer, rate.total_price
|
113
|
+
assert_kind_of Integer, rate.price
|
114
114
|
assert_instance_of String, rate.service_name
|
115
115
|
assert_instance_of String, rate.service_code
|
116
116
|
assert_instance_of Array, rate.package_rates
|
data/test/test_helper.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
require 'bundler/setup'
|
2
2
|
|
3
3
|
require 'minitest/autorun'
|
4
|
+
require "minitest/reporters"
|
4
5
|
require 'mocha/mini_test'
|
5
6
|
require 'timecop'
|
6
7
|
require 'business_time'
|
@@ -9,16 +10,25 @@ require 'active_shipping'
|
|
9
10
|
require 'logger'
|
10
11
|
require 'erb'
|
11
12
|
require 'pry'
|
13
|
+
require 'vcr'
|
14
|
+
require 'webmock/minitest'
|
12
15
|
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
Minitest::Test = MiniTest::Unit::TestCase
|
17
|
-
end
|
16
|
+
require_relative 'helpers/holiday_helpers.rb'
|
17
|
+
|
18
|
+
Minitest::Reporters.use! Minitest::Reporters::ProgressReporter.new(detailed_skip: !!ENV["CI"])
|
18
19
|
|
20
|
+
VCR.configure do |config|
|
21
|
+
config.cassette_library_dir = 'test/remote/vcr_cassettes'
|
22
|
+
config.allow_http_connections_when_no_cassette = true
|
23
|
+
config.hook_into :webmock
|
24
|
+
end
|
19
25
|
|
20
|
-
class
|
26
|
+
class ActiveSupport::TestCase
|
21
27
|
include ActiveShipping
|
28
|
+
|
29
|
+
def logger
|
30
|
+
@logger ||= Logger.new(STDERR)
|
31
|
+
end
|
22
32
|
end
|
23
33
|
|
24
34
|
module ActiveShipping::Test
|
data/test/unit/carrier_test.rb
CHANGED
@@ -1,63 +1,69 @@
|
|
1
1
|
require 'test_helper'
|
2
2
|
|
3
|
-
class CarrierTest <
|
3
|
+
class CarrierTest < ActiveSupport::TestCase
|
4
4
|
class ExampleCarrier < Carrier
|
5
5
|
cattr_reader :name
|
6
6
|
@@name = "Example Carrier"
|
7
7
|
end
|
8
8
|
|
9
|
-
|
9
|
+
setup do
|
10
10
|
@carrier = ExampleCarrier.new
|
11
11
|
end
|
12
12
|
|
13
|
-
|
13
|
+
test "#find_rates is not implemented" do
|
14
14
|
assert_raises NotImplementedError do
|
15
15
|
@carrier.find_rates(nil, nil, nil)
|
16
16
|
end
|
17
17
|
end
|
18
18
|
|
19
|
-
|
19
|
+
test "#create_shipment is not implemented" do
|
20
20
|
assert_raises NotImplementedError do
|
21
21
|
@carrier.create_shipment(nil, nil, nil)
|
22
22
|
end
|
23
23
|
end
|
24
24
|
|
25
|
-
|
25
|
+
test "#cancel_shipment is not implemented" do
|
26
26
|
assert_raises NotImplementedError do
|
27
27
|
@carrier.cancel_shipment(nil)
|
28
28
|
end
|
29
29
|
end
|
30
30
|
|
31
|
-
|
31
|
+
test "#find_tracking_info is not implemented" do
|
32
32
|
assert_raises NotImplementedError do
|
33
33
|
@carrier.find_tracking_info(nil)
|
34
34
|
end
|
35
35
|
end
|
36
36
|
|
37
|
-
|
38
|
-
|
37
|
+
test "#available_services is not implemented" do
|
38
|
+
assert_raises NotImplementedError do
|
39
|
+
@carrier.available_services(nil, nil)
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
test "#maximum_weight returns a Measured::Weight" do
|
44
|
+
assert_equal Measured::Weight.new(150, :pounds), @carrier.maximum_weight
|
39
45
|
end
|
40
46
|
|
41
|
-
|
47
|
+
test "#maximum_address_field_length default value" do
|
42
48
|
assert_equal 255, @carrier.maximum_address_field_length
|
43
49
|
end
|
44
50
|
|
45
|
-
|
51
|
+
test "#requirements is an empty array" do
|
46
52
|
assert_equal [], @carrier.send(:requirements)
|
47
53
|
end
|
48
54
|
|
49
|
-
|
55
|
+
test "#timestamp_from_business_day returns nil without a day" do
|
50
56
|
assert_nil @carrier.send(:timestamp_from_business_day, nil)
|
51
57
|
end
|
52
58
|
|
53
|
-
|
59
|
+
test "#save_request caches the last request on the object" do
|
54
60
|
request = Object.new
|
55
61
|
assert_nil @carrier.last_request
|
56
62
|
@carrier.send(:save_request, request)
|
57
63
|
assert_equal request, @carrier.last_request
|
58
64
|
end
|
59
65
|
|
60
|
-
|
66
|
+
test "#timestamp_from_business_day returns two days in the future" do
|
61
67
|
current = DateTime.parse("Tue 19 Jul 2016")
|
62
68
|
expected = DateTime.parse("Thu 21 Jul 2016")
|
63
69
|
|
@@ -66,7 +72,7 @@ class CarrierTest < Minitest::Test
|
|
66
72
|
end
|
67
73
|
end
|
68
74
|
|
69
|
-
|
75
|
+
test "#timestamp_from_business_day returns two days in the future over a weekend" do
|
70
76
|
current = DateTime.parse("Fri 22 Jul 2016")
|
71
77
|
expected = DateTime.parse("Tue 26 Jul 2016")
|
72
78
|
|
@@ -75,7 +81,7 @@ class CarrierTest < Minitest::Test
|
|
75
81
|
end
|
76
82
|
end
|
77
83
|
|
78
|
-
|
84
|
+
test "#timestamp_from_business_day returns fifteen days in the future" do
|
79
85
|
current = DateTime.parse("Wed 06 Jul 2016")
|
80
86
|
expected = DateTime.parse("Wed 27 Jul 2016") # includes 3 weekends
|
81
87
|
|
@@ -84,7 +90,7 @@ class CarrierTest < Minitest::Test
|
|
84
90
|
end
|
85
91
|
end
|
86
92
|
|
87
|
-
|
93
|
+
test "#timestamp_from_business_day handles saturday" do
|
88
94
|
current = DateTime.parse("Sat 09 Jul 2016")
|
89
95
|
expected = DateTime.parse("Mon 11 Jul 2016")
|
90
96
|
|
@@ -93,7 +99,7 @@ class CarrierTest < Minitest::Test
|
|
93
99
|
end
|
94
100
|
end
|
95
101
|
|
96
|
-
|
102
|
+
test "#timestamp_from_business_day handles sunday" do
|
97
103
|
current = DateTime.parse("Sun 10 Jul 2016")
|
98
104
|
expected = DateTime.parse("Mon 11 Jul 2016")
|
99
105
|
|
@@ -102,13 +108,13 @@ class CarrierTest < Minitest::Test
|
|
102
108
|
end
|
103
109
|
end
|
104
110
|
|
105
|
-
|
111
|
+
test "#timestamp_from_business_day returns a DateTime" do
|
106
112
|
Timecop.freeze(DateTime.parse("Tue 19 Jul 2016")) do
|
107
113
|
assert_equal DateTime, @carrier.send(:timestamp_from_business_day, 1).class
|
108
114
|
end
|
109
115
|
end
|
110
116
|
|
111
|
-
|
117
|
+
test ".default_location is a valid address with defaults" do
|
112
118
|
result = Carrier.default_location
|
113
119
|
|
114
120
|
assert_equal Location, result.class
|
@@ -121,10 +127,4 @@ class CarrierTest < Minitest::Test
|
|
121
127
|
assert_equal "1-310-285-1013", result.phone
|
122
128
|
assert_equal "1-310-275-8159", result.fax
|
123
129
|
end
|
124
|
-
|
125
|
-
def test_available_services_is_not_implemented
|
126
|
-
assert_raises NotImplementedError do
|
127
|
-
@carrier.available_services(nil, nil)
|
128
|
-
end
|
129
|
-
end
|
130
130
|
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
require 'test_helper'
|
2
2
|
|
3
|
-
class AustraliaPostTest <
|
3
|
+
class AustraliaPostTest < ActiveSupport::TestCase
|
4
4
|
include ActiveShipping::Test::Fixtures
|
5
5
|
|
6
6
|
def setup
|
@@ -11,13 +11,13 @@ class AustraliaPostTest < Minitest::Test
|
|
11
11
|
end
|
12
12
|
|
13
13
|
def test_service_domestic_simple_request
|
14
|
-
url = 'https://digitalapi.auspost.com.au/postage/parcel/domestic/service.json?from_postcode=2000&height=2&length=19&to_postcode=3108&weight=0.25&width=14'
|
14
|
+
url = 'https://digitalapi.auspost.com.au/postage/parcel/domestic/service.json?from_postcode=2000&height=2.0&length=19.0&to_postcode=3108&weight=0.25&width=14.0'
|
15
15
|
@carrier.expects(:commit).with(url).returns(json_fixture('australia_post/service_domestic'))
|
16
16
|
@carrier.find_rates(@sydney, @melbourne, package_fixtures[:book])
|
17
17
|
end
|
18
18
|
|
19
19
|
def test_service_domestic_combined_request
|
20
|
-
url_1 = 'https://digitalapi.auspost.com.au/postage/parcel/domestic/service.json?from_postcode=2000&height=2&length=19&to_postcode=3108&weight=0.25&width=14'
|
20
|
+
url_1 = 'https://digitalapi.auspost.com.au/postage/parcel/domestic/service.json?from_postcode=2000&height=2.0&length=19.0&to_postcode=3108&weight=0.25&width=14.0'
|
21
21
|
url_2 = 'https://digitalapi.auspost.com.au/postage/parcel/domestic/service.json?from_postcode=2000&height=2.54&length=2.54&to_postcode=3108&weight=0.23&width=2.54'
|
22
22
|
@carrier.expects(:commit).with(url_1).returns(json_fixture('australia_post/service_domestic'))
|
23
23
|
@carrier.expects(:commit).with(url_2).returns(json_fixture('australia_post/service_domestic_2'))
|
@@ -95,13 +95,13 @@ class AustraliaPostTest < Minitest::Test
|
|
95
95
|
end
|
96
96
|
|
97
97
|
def test_calculate_domestic_simple_request
|
98
|
-
url = 'https://digitalapi.auspost.com.au/postage/parcel/domestic/calculate.json?from_postcode=2000&height=2&length=19&service_code=AUS_PARCEL_EXPRESS&to_postcode=3108&weight=0.25&width=14'
|
98
|
+
url = 'https://digitalapi.auspost.com.au/postage/parcel/domestic/calculate.json?from_postcode=2000&height=2.0&length=19.0&service_code=AUS_PARCEL_EXPRESS&to_postcode=3108&weight=0.25&width=14.0'
|
99
99
|
@carrier.expects(:commit).with(url).returns(json_fixture('australia_post/calculate_domestic'))
|
100
100
|
@carrier.calculate_rates(@sydney, @melbourne, package_fixtures[:book], 'AUS_PARCEL_EXPRESS')
|
101
101
|
end
|
102
102
|
|
103
103
|
def test_calculate_domestic_combined_request
|
104
|
-
url_1 = 'https://digitalapi.auspost.com.au/postage/parcel/domestic/calculate.json?from_postcode=2000&height=2&length=19&service_code=AUS_PARCEL_EXPRESS&to_postcode=3108&weight=0.25&width=14'
|
104
|
+
url_1 = 'https://digitalapi.auspost.com.au/postage/parcel/domestic/calculate.json?from_postcode=2000&height=2.0&length=19.0&service_code=AUS_PARCEL_EXPRESS&to_postcode=3108&weight=0.25&width=14.0'
|
105
105
|
url_2 = 'https://digitalapi.auspost.com.au/postage/parcel/domestic/calculate.json?from_postcode=2000&height=2.54&length=2.54&service_code=AUS_PARCEL_EXPRESS&to_postcode=3108&weight=0.23&width=2.54'
|
106
106
|
@carrier.expects(:commit).with(url_1).returns(json_fixture('australia_post/calculate_domestic'))
|
107
107
|
@carrier.expects(:commit).with(url_2).returns(json_fixture('australia_post/calculate_domestic_2'))
|
@@ -1,6 +1,6 @@
|
|
1
1
|
require 'test_helper'
|
2
2
|
|
3
|
-
class CanadaPostPwsRatingTest <
|
3
|
+
class CanadaPostPwsRatingTest < ActiveSupport::TestCase
|
4
4
|
include ActiveShipping::Test::Fixtures
|
5
5
|
|
6
6
|
def setup
|
@@ -343,20 +343,6 @@ class CanadaPostPwsRatingTest < Minitest::Test
|
|
343
343
|
assert_equal 150, response[:restrictions][:max_width]
|
344
344
|
end
|
345
345
|
|
346
|
-
def test_parse_find_service_options_response
|
347
|
-
body = xml_fixture('canadapost_pws/service_options_response_priority_worldwide')
|
348
|
-
response = @cp.parse_service_options_response(body)
|
349
|
-
assert_equal 3, response[:options].size
|
350
|
-
assert_equal 0, response[:restrictions][:min_weight]
|
351
|
-
assert_equal 0, response[:restrictions][:max_weight]
|
352
|
-
assert_equal 0, response[:restrictions][:min_length]
|
353
|
-
assert_equal 0, response[:restrictions][:min_height]
|
354
|
-
assert_equal 0, response[:restrictions][:min_width]
|
355
|
-
assert_equal 0, response[:restrictions][:max_length]
|
356
|
-
assert_equal 0, response[:restrictions][:max_height]
|
357
|
-
assert_equal 0, response[:restrictions][:max_width]
|
358
|
-
end
|
359
|
-
|
360
346
|
def test_parse_find_option_response
|
361
347
|
body = xml_fixture('canadapost_pws/option_response')
|
362
348
|
response = @cp.parse_option_response(body)
|
@@ -1,6 +1,6 @@
|
|
1
1
|
require 'test_helper'
|
2
2
|
|
3
|
-
class CanadaPostPwsRegisterTest <
|
3
|
+
class CanadaPostPwsRegisterTest < ActiveSupport::TestCase
|
4
4
|
include ActiveShipping::Test::Fixtures
|
5
5
|
|
6
6
|
def setup
|
@@ -58,20 +58,6 @@ class CanadaPostPwsRegisterTest < Minitest::Test
|
|
58
58
|
assert_equal false, response.has_default_credit_card
|
59
59
|
end
|
60
60
|
|
61
|
-
def test_retrieve_merchant_details_without_contract_number
|
62
|
-
endpoint = @cp.endpoint + "ot/token/1234567890"
|
63
|
-
response = xml_fixture('canadapost_pws/merchant_details_response_no_contract_number')
|
64
|
-
@cp.expects(:ssl_get).with(endpoint, anything).returns(response)
|
65
|
-
|
66
|
-
response = @cp.retrieve_merchant_details(:token_id => '1234567890')
|
67
|
-
assert response.is_a?(CPPWSMerchantDetailsResponse)
|
68
|
-
assert_equal "1234567890", response.customer_number
|
69
|
-
assert_nil response.contract_number
|
70
|
-
assert_equal "1234567890123456", response.username
|
71
|
-
assert_equal "12343567890123456789012", response.password
|
72
|
-
assert_equal true, response.has_default_credit_card
|
73
|
-
end
|
74
|
-
|
75
61
|
def test_retrieve_merchant_with_error
|
76
62
|
endpoint = @cp.endpoint + "ot/token/1234567890"
|
77
63
|
response = xml_fixture('canadapost_pws/merchant_details_error')
|
@@ -1,5 +1,5 @@
|
|
1
1
|
require 'test_helper'
|
2
|
-
class CanadaPostPwsShippingTest <
|
2
|
+
class CanadaPostPwsShippingTest < ActiveSupport::TestCase
|
3
3
|
include ActiveShipping::Test::Fixtures
|
4
4
|
|
5
5
|
def setup
|
@@ -120,18 +120,6 @@ class CanadaPostPwsShippingTest < Minitest::Test
|
|
120
120
|
refute request.blank?
|
121
121
|
end
|
122
122
|
|
123
|
-
def test_create_shipment_request_with_incomplete_options_hash
|
124
|
-
bad_shipping_opts = { :cod_amount => 50.00, :cov_amount => 100.00 }
|
125
|
-
options = @default_options.merge(bad_shipping_opts)
|
126
|
-
request = @cp.build_shipment_request(@home_params, @paris_params, @pkg1, @line_item1, options)
|
127
|
-
refute request.blank?
|
128
|
-
|
129
|
-
doc = Nokogiri.XML(request)
|
130
|
-
doc.remove_namespaces!
|
131
|
-
|
132
|
-
assert_nil doc.at('non-contract-shipment').at('delivery-spec').at('options')
|
133
|
-
end
|
134
|
-
|
135
123
|
def test_create_shipment_request_with_options
|
136
124
|
options = @default_options.merge(@shipping_opts1)
|
137
125
|
request = @cp.build_shipment_request(@home_params, @paris_params, @pkg1, @line_item1, options)
|
@@ -1,6 +1,6 @@
|
|
1
1
|
require 'test_helper'
|
2
2
|
|
3
|
-
class CanadaPostPwsTest <
|
3
|
+
class CanadaPostPwsTest < ActiveSupport::TestCase
|
4
4
|
|
5
5
|
def setup
|
6
6
|
credentials = { platform_id: 123, api_key: '456', secret: '789' }
|
@@ -10,17 +10,17 @@ class CanadaPostPwsTest < Minitest::Test
|
|
10
10
|
def test_get_sanitized_postal_code_location_nil
|
11
11
|
postal_code = @cp.send(:get_sanitized_postal_code, nil)
|
12
12
|
|
13
|
-
|
13
|
+
assert_equal nil, postal_code
|
14
14
|
end
|
15
15
|
|
16
16
|
def test_get_sanitized_postal_code_postal_code_nil
|
17
17
|
location = Location.new(name: 'Test test')
|
18
18
|
|
19
|
-
|
19
|
+
assert_equal nil, location.postal_code
|
20
20
|
|
21
21
|
postal_code = @cp.send(:get_sanitized_postal_code, location)
|
22
22
|
|
23
|
-
|
23
|
+
assert_equal nil, postal_code
|
24
24
|
end
|
25
25
|
|
26
26
|
def test_get_sanitized_postal_code_spaces
|