active_shipping 1.13.4 → 1.14.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 053fd1f8bb1f8703c987c04bae54890113da7279
4
- data.tar.gz: a13860a75c2feb3ea8ce4586473c3a560c3a800e
3
+ metadata.gz: cd3f080f7ff848e61dd530d4c4562c8010e76a01
4
+ data.tar.gz: 7b97efd00ca16978a0bf77b1a20c6244bf454de7
5
5
  SHA512:
6
- metadata.gz: cebea6659ce0cf9a316149886521fe07fc6563c894bdc6dd6ccc5b407c950118272d3cbcba0d35f00d63b5a5c02c4d5238eaa78223865d77d2cf73ef3cf02bb4
7
- data.tar.gz: 69d7a363705c521bda896ead248d6605209815d7ee9b410c39be15ea4f53f0da4c955f02f7e594ae3acac0a049cdf6cb14a22161d538bfa81f30bef773688a23
6
+ metadata.gz: 9d3acc9f7ed6d393ef7ad013e4f207a1dcdacf50b7ef1d06f5ba206575a2f8cea0bda68b02e02cea4b25635dd5932700186218d0aaf8bf3ac27623d421058a13
7
+ data.tar.gz: b4765b284a95d26de362fbbd4f0385a770a08a259e290d36e4d3443a3ea31f058f7c6547db74fa1ddd9fa0033d0f0253a9f74d09bd2299b38b3e1e156df13907
data/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # ActiveShipping CHANGELOG
2
2
 
3
+ ### v1.14.0
4
+ - Update Correios default services list.
5
+ - Fix CanadaPostPWS from generating an empty options tag.
6
+ - Allow contract-number on CanadaPost merchant detail's response to be nil.
7
+ - Fix a flakey UPS remote test that would fail only on Fridays.
8
+
3
9
  ### v1.13.4
4
10
  - Upcase postal code for CanadaPostPWS
5
11
  - Fix failing USPS test
@@ -526,7 +526,7 @@ module ActiveShipping
526
526
  raise "No Merchant Info" if doc.root.at('customer-number').blank?
527
527
  options = {
528
528
  :customer_number => doc.root.at('customer-number').text,
529
- :contract_number => doc.root.at('contract-number').text,
529
+ :contract_number => doc.root.at('contract-number').try(:text),
530
530
  :username => doc.root.at('merchant-username').text,
531
531
  :password => doc.root.at('merchant-password').text,
532
532
  :has_default_credit_card => doc.root.at('has-default-credit-card').text == 'true'
@@ -728,39 +728,43 @@ module ActiveShipping
728
728
 
729
729
  def shipping_options_node(xml, available_options, options = {})
730
730
  return if (options.symbolize_keys.keys & available_options).empty?
731
- xml.public_send('options') do
732
-
733
- if options[:cod] && options[:cod_amount]
734
- xml.public_send('option') do
735
- xml.public_send('option-code', 'COD')
736
- xml.public_send('option-amount', options[:cod_amount])
737
- xml.public_send('option-qualifier-1', options[:cod_includes_shipping]) unless options[:cod_includes_shipping].blank?
738
- xml.public_send('option-qualifier-2', options[:cod_method_of_payment]) unless options[:cod_method_of_payment].blank?
731
+
732
+ options_doc = Nokogiri::XML::Builder.new do |options_xml|
733
+ options_xml.public_send('options') do
734
+ if options[:cod] && options[:cod_amount]
735
+ options_xml.public_send('option') do
736
+ options_xml.public_send('option-code', 'COD')
737
+ options_xml.public_send('option-amount', options[:cod_amount])
738
+ options_xml.public_send('option-qualifier-1', options[:cod_includes_shipping]) unless options[:cod_includes_shipping].blank?
739
+ options_xml.public_send('option-qualifier-2', options[:cod_method_of_payment]) unless options[:cod_method_of_payment].blank?
740
+ end
739
741
  end
740
- end
741
742
 
742
- if options[:cov]
743
- xml.public_send('option') do
744
- xml.public_send('option-code', 'COV')
745
- xml.public_send('option-amount', options[:cov_amount]) unless options[:cov_amount].blank?
743
+ if options[:cov]
744
+ options_xml.public_send('option') do
745
+ options_xml.public_send('option-code', 'COV')
746
+ options_xml.public_send('option-amount', options[:cov_amount]) unless options[:cov_amount].blank?
747
+ end
746
748
  end
747
- end
748
749
 
749
- if options[:d2po]
750
- xml.public_send('option') do
751
- xml.public_send('option-code', 'D2PO')
752
- xml.public_send('option-qualifier-2'. options[:d2po_office_id]) unless options[:d2po_office_id].blank?
750
+ if options[:d2po]
751
+ options_xml.public_send('option') do
752
+ options_xml.public_send('option-code', 'D2PO')
753
+ options_xml.public_send('option-qualifier-2'. options[:d2po_office_id]) unless options[:d2po_office_id].blank?
754
+ end
753
755
  end
754
- end
755
756
 
756
- [:so, :dc, :pa18, :pa19, :hfp, :dns, :lad, :rase, :rts, :aban].each do |code|
757
- if options[code]
758
- xml.public_send('option') do
759
- xml.public_send('option-code', code.to_s.upcase)
757
+ [:so, :dc, :pa18, :pa19, :hfp, :dns, :lad, :rase, :rts, :aban].each do |code|
758
+ if options[code]
759
+ options_xml.public_send('option') do
760
+ options_xml.public_send('option-code', code.to_s.upcase)
761
+ end
760
762
  end
761
763
  end
762
764
  end
763
765
  end
766
+
767
+ xml.parent << options_doc.doc.at("options") if options_doc.doc.at("options").children.any?
764
768
  end
765
769
 
766
770
  def expected_date_from_node(node)
@@ -21,8 +21,10 @@ module ActiveShipping
21
21
 
22
22
  protected
23
23
 
24
- DEFAULT_SERVICES = [41106, 40010]
24
+ DEFAULT_SERVICES = ['04510', '04014']
25
25
  AVAILABLE_SERVICES = {
26
+ '04510' => 'PAC sem contrato',
27
+ '04014' => 'SEDEX sem contrato',
26
28
  41106 => 'PAC sem contrato',
27
29
  41068 => 'PAC com contrato',
28
30
  41300 => 'PAC para grandes formatos',
@@ -1,3 +1,3 @@
1
1
  module ActiveShipping
2
- VERSION = "1.13.4"
2
+ VERSION = "1.14.0"
3
3
  end
@@ -0,0 +1,7 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <merchant-info xmlns="http://www.canadapost.ca/ws/merchant/registration">
3
+ <customer-number>1234567890</customer-number>
4
+ <merchant-username>1234567890123456</merchant-username>
5
+ <merchant-password>12343567890123456789012</merchant-password>
6
+ <has-default-credit-card>true</has-default-credit-card>
7
+ </merchant-info>
@@ -387,7 +387,8 @@ class RemoteUPSTest < Minitest::Test
387
387
  assert response.success?
388
388
  refute_empty response.delivery_estimates
389
389
  ww_express_estimate = response.delivery_estimates.select {|de| de.service_name == "UPS Worldwide Express"}.first
390
- assert_equal 1.business_days.after(today), ww_express_estimate.date
390
+ expected_estimate = today.friday? ? today + 1 : 1.business_days.after(today)
391
+ assert_equal expected_estimate, ww_express_estimate.date
391
392
  end
392
393
 
393
394
  def test_void_shipment
@@ -58,6 +58,20 @@ 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
+
61
75
  def test_retrieve_merchant_with_error
62
76
  endpoint = @cp.endpoint + "ot/token/1234567890"
63
77
  response = xml_fixture('canadapost_pws/merchant_details_error')
@@ -120,6 +120,18 @@ 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
+
123
135
  def test_create_shipment_request_with_options
124
136
  options = @default_options.merge(@shipping_opts1)
125
137
  request = @cp.build_shipment_request(@home_params, @paris_params, @pkg1, @line_item1, options)
@@ -124,7 +124,7 @@ class CorreiosTest < Minitest::Test
124
124
  "sCdMaoPropria=S",
125
125
  "nVlValorDeclarado=10%2C5",
126
126
  "sCdAvisoRecebimento=S",
127
- "nCdServico=41106%2C40010",
127
+ "nCdServico=04510%2C04014",
128
128
  "sCepOrigem=01415000",
129
129
  "sCepDestino=38700000",
130
130
  "nVlPeso=0.25",
@@ -220,7 +220,7 @@ class CorreiosTest < Minitest::Test
220
220
  services = Correios.available_services
221
221
 
222
222
  assert_kind_of Hash, services
223
- assert_equal 19, services.size
223
+ assert_equal 21, services.size
224
224
  assert_equal 'PAC sem contrato', services[41106]
225
225
  assert_equal 'PAC com contrato', services[41068]
226
226
  assert_equal 'PAC para grandes formatos', services[41300]
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: active_shipping
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.13.4
4
+ version: 1.14.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Shopify
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-04-20 00:00:00.000000000 Z
11
+ date: 2017-05-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: quantified
@@ -256,6 +256,7 @@ files:
256
256
  - test/fixtures/xml/canadapost_pws/dnc_tracking_details_en.xml
257
257
  - test/fixtures/xml/canadapost_pws/merchant_details_error.xml
258
258
  - test/fixtures/xml/canadapost_pws/merchant_details_response.xml
259
+ - test/fixtures/xml/canadapost_pws/merchant_details_response_no_contract_number.xml
259
260
  - test/fixtures/xml/canadapost_pws/option_response.xml
260
261
  - test/fixtures/xml/canadapost_pws/option_response_no_conflicts.xml
261
262
  - test/fixtures/xml/canadapost_pws/rates_info.xml
@@ -491,6 +492,7 @@ test_files:
491
492
  - test/fixtures/xml/canadapost_pws/dnc_tracking_details_en.xml
492
493
  - test/fixtures/xml/canadapost_pws/merchant_details_error.xml
493
494
  - test/fixtures/xml/canadapost_pws/merchant_details_response.xml
495
+ - test/fixtures/xml/canadapost_pws/merchant_details_response_no_contract_number.xml
494
496
  - test/fixtures/xml/canadapost_pws/option_response.xml
495
497
  - test/fixtures/xml/canadapost_pws/option_response_no_conflicts.xml
496
498
  - test/fixtures/xml/canadapost_pws/rates_info.xml