tax_cloud 0.3.0 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.rubocop.yml +8 -25
- data/.rubocop_todo.yml +47 -0
- data/.travis.yml +5 -5
- data/CHANGELOG.rdoc +11 -0
- data/CONTRIBUTORS.txt +3 -0
- data/Gemfile +16 -5
- data/LICENSE.rdoc +1 -1
- data/README.rdoc +12 -8
- data/Rakefile +7 -11
- data/lib/config/locales/en.yml +2 -2
- data/lib/hash.rb +3 -4
- data/lib/tasks/tax_cloud.rake +4 -4
- data/lib/tasks/tax_code_groups.rake +11 -11
- data/lib/tasks/tax_codes.rake +12 -12
- data/lib/tax_cloud.rb +8 -3
- data/lib/tax_cloud/address.rb +10 -5
- data/lib/tax_cloud/cart_item.rb +2 -0
- data/lib/tax_cloud/client.rb +13 -3
- data/lib/tax_cloud/configuration.rb +13 -2
- data/lib/tax_cloud/errors.rb +2 -0
- data/lib/tax_cloud/errors/api_error.rb +3 -3
- data/lib/tax_cloud/errors/missing_config_error.rb +2 -1
- data/lib/tax_cloud/errors/missing_config_option_error.rb +2 -1
- data/lib/tax_cloud/errors/soap_error.rb +6 -6
- data/lib/tax_cloud/errors/tax_cloud_error.rb +4 -3
- data/lib/tax_cloud/errors/unexpected_soap_response_error.rb +3 -3
- data/lib/tax_cloud/record.rb +2 -0
- data/lib/tax_cloud/responses.rb +2 -0
- data/lib/tax_cloud/responses/authorized.rb +3 -1
- data/lib/tax_cloud/responses/authorized_with_capture.rb +3 -1
- data/lib/tax_cloud/responses/base.rb +5 -4
- data/lib/tax_cloud/responses/captured.rb +3 -1
- data/lib/tax_cloud/responses/cart_item.rb +6 -2
- data/lib/tax_cloud/responses/generic.rb +2 -0
- data/lib/tax_cloud/responses/lookup.rb +10 -8
- data/lib/tax_cloud/responses/ping.rb +3 -1
- data/lib/tax_cloud/responses/returned.rb +3 -1
- data/lib/tax_cloud/responses/tax_code_groups.rb +3 -1
- data/lib/tax_cloud/responses/tax_codes.rb +3 -1
- data/lib/tax_cloud/responses/tax_codes_by_group.rb +3 -1
- data/lib/tax_cloud/responses/verify_address.rb +3 -1
- data/lib/tax_cloud/tax_code.rb +2 -0
- data/lib/tax_cloud/tax_code_constants.rb +262 -260
- data/lib/tax_cloud/tax_code_group.rb +3 -1
- data/lib/tax_cloud/tax_code_group_constants.rb +2 -0
- data/lib/tax_cloud/tax_code_groups.rb +3 -1
- data/lib/tax_cloud/tax_codes.rb +3 -1
- data/lib/tax_cloud/transaction.rb +2 -0
- data/lib/tax_cloud/version.rb +3 -1
- data/tax_cloud.gemspec +16 -18
- data/test/cassettes/authorized.yml +6 -6
- data/test/cassettes/authorized_with_capture.yml +6 -6
- data/test/cassettes/authorized_with_localized_time.yml +6 -6
- data/test/cassettes/captured.yml +7 -7
- data/test/cassettes/get_tic_groups.yml +5 -5
- data/test/cassettes/get_tics.yml +5 -5
- data/test/cassettes/get_tics_by_group.yml +5 -5
- data/test/cassettes/invalid_soap_call.yml +5 -5
- data/test/cassettes/lookup.yml +5 -5
- data/test/cassettes/lookup_ny.yml +5 -5
- data/test/cassettes/ping.yml +5 -5
- data/test/cassettes/ping_with_invalid_credentials.yml +5 -5
- data/test/cassettes/ping_with_invalid_response.yml +5 -5
- data/test/cassettes/returned.yml +7 -7
- data/test/cassettes/verify_bad_address.yml +5 -5
- data/test/cassettes/verify_good_address.yml +5 -5
- data/test/helper.rb +3 -1
- data/test/test_address.rb +3 -1
- data/test/test_cart_item.rb +3 -1
- data/test/test_client.rb +4 -2
- data/test/test_configuration_optional_keys.rb +44 -0
- data/test/{test_configuration.rb → test_configuration_required_keys.rb} +6 -4
- data/test/test_lookup_response.rb +22 -0
- data/test/test_setup.rb +3 -1
- data/test/test_soap.rb +3 -1
- data/test/test_tax_code_groups.rb +4 -2
- data/test/test_tax_codes.rb +3 -1
- data/test/test_transaction.rb +3 -1
- data/test/test_transaction_ny.rb +3 -1
- data/test/vcr_setup.rb +2 -0
- metadata +28 -96
data/test/cassettes/ping.yml
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
http_interactions:
|
3
3
|
- request:
|
4
4
|
method: get
|
5
|
-
uri: https://
|
5
|
+
uri: https://asmx.taxcloud.com/1.0/?wsdl
|
6
6
|
body:
|
7
7
|
encoding: US-ASCII
|
8
8
|
string: ''
|
@@ -719,17 +719,17 @@ http_interactions:
|
|
719
719
|
part=\"Body\" />\r\n </wsdl:output>\r\n </wsdl:operation>\r\n </wsdl:binding>\r\n
|
720
720
|
\ <wsdl:service name=\"TaxCloud\">\r\n <wsdl:documentation xmlns:wsdl=\"http://schemas.xmlsoap.org/wsdl/\">TaxCloud
|
721
721
|
Web Service</wsdl:documentation>\r\n <wsdl:port name=\"TaxCloudSoap\" binding=\"tns:TaxCloudSoap\">\r\n
|
722
|
-
\ <soap:address location=\"https://
|
722
|
+
\ <soap:address location=\"https://asmx.taxcloud.com/1.0/TaxCloud.asmx\"
|
723
723
|
/>\r\n </wsdl:port>\r\n <wsdl:port name=\"TaxCloudSoap12\" binding=\"tns:TaxCloudSoap12\">\r\n
|
724
|
-
\ <soap12:address location=\"https://
|
724
|
+
\ <soap12:address location=\"https://asmx.taxcloud.com/1.0/TaxCloud.asmx\"
|
725
725
|
/>\r\n </wsdl:port>\r\n <wsdl:port name=\"TaxCloudHttpPost\" binding=\"tns:TaxCloudHttpPost\">\r\n
|
726
|
-
\ <http:address location=\"https://
|
726
|
+
\ <http:address location=\"https://asmx.taxcloud.com/1.0/TaxCloud.asmx\"
|
727
727
|
/>\r\n </wsdl:port>\r\n </wsdl:service>\r\n</wsdl:definitions>"
|
728
728
|
http_version:
|
729
729
|
recorded_at: Thu, 09 Jan 2014 16:03:39 GMT
|
730
730
|
- request:
|
731
731
|
method: post
|
732
|
-
uri: https://
|
732
|
+
uri: https://asmx.taxcloud.com/1.0/TaxCloud.asmx
|
733
733
|
body:
|
734
734
|
encoding: US-ASCII
|
735
735
|
string: <?xml version="1.0" encoding="UTF-8"?><env:Envelope xmlns:xsd="http://www.w3.org/2001/XMLSchema"
|
@@ -2,7 +2,7 @@
|
|
2
2
|
http_interactions:
|
3
3
|
- request:
|
4
4
|
method: get
|
5
|
-
uri: https://
|
5
|
+
uri: https://asmx.taxcloud.com/1.0/?wsdl
|
6
6
|
body:
|
7
7
|
encoding: US-ASCII
|
8
8
|
string: ''
|
@@ -719,17 +719,17 @@ http_interactions:
|
|
719
719
|
part=\"Body\" />\r\n </wsdl:output>\r\n </wsdl:operation>\r\n </wsdl:binding>\r\n
|
720
720
|
\ <wsdl:service name=\"TaxCloud\">\r\n <wsdl:documentation xmlns:wsdl=\"http://schemas.xmlsoap.org/wsdl/\">TaxCloud
|
721
721
|
Web Service</wsdl:documentation>\r\n <wsdl:port name=\"TaxCloudSoap\" binding=\"tns:TaxCloudSoap\">\r\n
|
722
|
-
\ <soap:address location=\"https://
|
722
|
+
\ <soap:address location=\"https://asmx.taxcloud.com/1.0/TaxCloud.asmx\"
|
723
723
|
/>\r\n </wsdl:port>\r\n <wsdl:port name=\"TaxCloudSoap12\" binding=\"tns:TaxCloudSoap12\">\r\n
|
724
|
-
\ <soap12:address location=\"https://
|
724
|
+
\ <soap12:address location=\"https://asmx.taxcloud.com/1.0/TaxCloud.asmx\"
|
725
725
|
/>\r\n </wsdl:port>\r\n <wsdl:port name=\"TaxCloudHttpPost\" binding=\"tns:TaxCloudHttpPost\">\r\n
|
726
|
-
\ <http:address location=\"https://
|
726
|
+
\ <http:address location=\"https://asmx.taxcloud.com/1.0/TaxCloud.asmx\"
|
727
727
|
/>\r\n </wsdl:port>\r\n </wsdl:service>\r\n</wsdl:definitions>"
|
728
728
|
http_version:
|
729
729
|
recorded_at: Thu, 09 Jan 2014 16:03:39 GMT
|
730
730
|
- request:
|
731
731
|
method: post
|
732
|
-
uri: https://
|
732
|
+
uri: https://asmx.taxcloud.com/1.0/TaxCloud.asmx
|
733
733
|
body:
|
734
734
|
encoding: US-ASCII
|
735
735
|
string: <?xml version="1.0" encoding="UTF-8"?><env:Envelope xmlns:xsd="http://www.w3.org/2001/XMLSchema"
|
@@ -2,7 +2,7 @@
|
|
2
2
|
http_interactions:
|
3
3
|
- request:
|
4
4
|
method: get
|
5
|
-
uri: https://
|
5
|
+
uri: https://asmx.taxcloud.com/1.0/?wsdl
|
6
6
|
body:
|
7
7
|
encoding: US-ASCII
|
8
8
|
string: ''
|
@@ -719,17 +719,17 @@ http_interactions:
|
|
719
719
|
part=\"Body\" />\r\n </wsdl:output>\r\n </wsdl:operation>\r\n </wsdl:binding>\r\n
|
720
720
|
\ <wsdl:service name=\"TaxCloud\">\r\n <wsdl:documentation xmlns:wsdl=\"http://schemas.xmlsoap.org/wsdl/\">TaxCloud
|
721
721
|
Web Service</wsdl:documentation>\r\n <wsdl:port name=\"TaxCloudSoap\" binding=\"tns:TaxCloudSoap\">\r\n
|
722
|
-
\ <soap:address location=\"https://
|
722
|
+
\ <soap:address location=\"https://asmx.taxcloud.com/1.0/TaxCloud.asmx\"
|
723
723
|
/>\r\n </wsdl:port>\r\n <wsdl:port name=\"TaxCloudSoap12\" binding=\"tns:TaxCloudSoap12\">\r\n
|
724
|
-
\ <soap12:address location=\"https://
|
724
|
+
\ <soap12:address location=\"https://asmx.taxcloud.com/1.0/TaxCloud.asmx\"
|
725
725
|
/>\r\n </wsdl:port>\r\n <wsdl:port name=\"TaxCloudHttpPost\" binding=\"tns:TaxCloudHttpPost\">\r\n
|
726
|
-
\ <http:address location=\"https://
|
726
|
+
\ <http:address location=\"https://asmx.taxcloud.com/1.0/TaxCloud.asmx\"
|
727
727
|
/>\r\n </wsdl:port>\r\n </wsdl:service>\r\n</wsdl:definitions>"
|
728
728
|
http_version:
|
729
729
|
recorded_at: Thu, 09 Jan 2014 16:03:39 GMT
|
730
730
|
- request:
|
731
731
|
method: post
|
732
|
-
uri: https://
|
732
|
+
uri: https://asmx.taxcloud.com/1.0/TaxCloud.asmx
|
733
733
|
body:
|
734
734
|
encoding: US-ASCII
|
735
735
|
string: <?xml version="1.0" encoding="UTF-8"?><env:Envelope xmlns:xsd="http://www.w3.org/2001/XMLSchema"
|
data/test/cassettes/returned.yml
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
http_interactions:
|
3
3
|
- request:
|
4
4
|
method: get
|
5
|
-
uri: https://
|
5
|
+
uri: https://asmx.taxcloud.com/1.0/?wsdl
|
6
6
|
body:
|
7
7
|
encoding: US-ASCII
|
8
8
|
string: ''
|
@@ -719,17 +719,17 @@ http_interactions:
|
|
719
719
|
part=\"Body\" />\r\n </wsdl:output>\r\n </wsdl:operation>\r\n </wsdl:binding>\r\n
|
720
720
|
\ <wsdl:service name=\"TaxCloud\">\r\n <wsdl:documentation xmlns:wsdl=\"http://schemas.xmlsoap.org/wsdl/\">TaxCloud
|
721
721
|
Web Service</wsdl:documentation>\r\n <wsdl:port name=\"TaxCloudSoap\" binding=\"tns:TaxCloudSoap\">\r\n
|
722
|
-
\ <soap:address location=\"https://
|
722
|
+
\ <soap:address location=\"https://asmx.taxcloud.com/1.0/TaxCloud.asmx\"
|
723
723
|
/>\r\n </wsdl:port>\r\n <wsdl:port name=\"TaxCloudSoap12\" binding=\"tns:TaxCloudSoap12\">\r\n
|
724
|
-
\ <soap12:address location=\"https://
|
724
|
+
\ <soap12:address location=\"https://asmx.taxcloud.com/1.0/TaxCloud.asmx\"
|
725
725
|
/>\r\n </wsdl:port>\r\n <wsdl:port name=\"TaxCloudHttpPost\" binding=\"tns:TaxCloudHttpPost\">\r\n
|
726
|
-
\ <http:address location=\"https://
|
726
|
+
\ <http:address location=\"https://asmx.taxcloud.com/1.0/TaxCloud.asmx\"
|
727
727
|
/>\r\n </wsdl:port>\r\n </wsdl:service>\r\n</wsdl:definitions>"
|
728
728
|
http_version:
|
729
729
|
recorded_at: Thu, 09 Jan 2014 16:03:39 GMT
|
730
730
|
- request:
|
731
731
|
method: post
|
732
|
-
uri: https://
|
732
|
+
uri: https://asmx.taxcloud.com/1.0/TaxCloud.asmx
|
733
733
|
body:
|
734
734
|
encoding: US-ASCII
|
735
735
|
string: <?xml version="1.0" encoding="UTF-8"?><env:Envelope xmlns:xsd="http://www.w3.org/2001/XMLSchema"
|
@@ -779,7 +779,7 @@ http_interactions:
|
|
779
779
|
recorded_at: Fri, 01 Mar 2013 22:58:21 GMT
|
780
780
|
- request:
|
781
781
|
method: post
|
782
|
-
uri: https://
|
782
|
+
uri: https://asmx.taxcloud.com/1.0/TaxCloud.asmx
|
783
783
|
body:
|
784
784
|
encoding: US-ASCII
|
785
785
|
string: <?xml version="1.0" encoding="UTF-8"?><env:Envelope xmlns:xsd="http://www.w3.org/2001/XMLSchema"
|
@@ -825,7 +825,7 @@ http_interactions:
|
|
825
825
|
recorded_at: Fri, 01 Mar 2013 22:58:21 GMT
|
826
826
|
- request:
|
827
827
|
method: post
|
828
|
-
uri: https://
|
828
|
+
uri: https://asmx.taxcloud.com/1.0/TaxCloud.asmx
|
829
829
|
body:
|
830
830
|
encoding: US-ASCII
|
831
831
|
string: <?xml version="1.0" encoding="UTF-8"?><env:Envelope xmlns:xsd="http://www.w3.org/2001/XMLSchema"
|
@@ -2,7 +2,7 @@
|
|
2
2
|
http_interactions:
|
3
3
|
- request:
|
4
4
|
method: get
|
5
|
-
uri: https://
|
5
|
+
uri: https://asmx.taxcloud.com/1.0/?wsdl
|
6
6
|
body:
|
7
7
|
encoding: US-ASCII
|
8
8
|
string: ''
|
@@ -719,17 +719,17 @@ http_interactions:
|
|
719
719
|
part=\"Body\" />\r\n </wsdl:output>\r\n </wsdl:operation>\r\n </wsdl:binding>\r\n
|
720
720
|
\ <wsdl:service name=\"TaxCloud\">\r\n <wsdl:documentation xmlns:wsdl=\"http://schemas.xmlsoap.org/wsdl/\">TaxCloud
|
721
721
|
Web Service</wsdl:documentation>\r\n <wsdl:port name=\"TaxCloudSoap\" binding=\"tns:TaxCloudSoap\">\r\n
|
722
|
-
\ <soap:address location=\"https://
|
722
|
+
\ <soap:address location=\"https://asmx.taxcloud.com/1.0/TaxCloud.asmx\"
|
723
723
|
/>\r\n </wsdl:port>\r\n <wsdl:port name=\"TaxCloudSoap12\" binding=\"tns:TaxCloudSoap12\">\r\n
|
724
|
-
\ <soap12:address location=\"https://
|
724
|
+
\ <soap12:address location=\"https://asmx.taxcloud.com/1.0/TaxCloud.asmx\"
|
725
725
|
/>\r\n </wsdl:port>\r\n <wsdl:port name=\"TaxCloudHttpPost\" binding=\"tns:TaxCloudHttpPost\">\r\n
|
726
|
-
\ <http:address location=\"https://
|
726
|
+
\ <http:address location=\"https://asmx.taxcloud.com/1.0/TaxCloud.asmx\"
|
727
727
|
/>\r\n </wsdl:port>\r\n </wsdl:service>\r\n</wsdl:definitions>"
|
728
728
|
http_version:
|
729
729
|
recorded_at: Thu, 09 Jan 2014 16:03:39 GMT
|
730
730
|
- request:
|
731
731
|
method: post
|
732
|
-
uri: https://
|
732
|
+
uri: https://asmx.taxcloud.com/1.0/TaxCloud.asmx
|
733
733
|
body:
|
734
734
|
encoding: UTF-8
|
735
735
|
string: <?xml version="1.0" encoding="UTF-8"?><env:Envelope xmlns:xsd="http://www.w3.org/2001/XMLSchema"
|
@@ -2,7 +2,7 @@
|
|
2
2
|
http_interactions:
|
3
3
|
- request:
|
4
4
|
method: get
|
5
|
-
uri: https://
|
5
|
+
uri: https://asmx.taxcloud.com/1.0/?wsdl
|
6
6
|
body:
|
7
7
|
encoding: US-ASCII
|
8
8
|
string: ''
|
@@ -719,17 +719,17 @@ http_interactions:
|
|
719
719
|
part=\"Body\" />\r\n </wsdl:output>\r\n </wsdl:operation>\r\n </wsdl:binding>\r\n
|
720
720
|
\ <wsdl:service name=\"TaxCloud\">\r\n <wsdl:documentation xmlns:wsdl=\"http://schemas.xmlsoap.org/wsdl/\">TaxCloud
|
721
721
|
Web Service</wsdl:documentation>\r\n <wsdl:port name=\"TaxCloudSoap\" binding=\"tns:TaxCloudSoap\">\r\n
|
722
|
-
\ <soap:address location=\"https://
|
722
|
+
\ <soap:address location=\"https://asmx.taxcloud.com/1.0/TaxCloud.asmx\"
|
723
723
|
/>\r\n </wsdl:port>\r\n <wsdl:port name=\"TaxCloudSoap12\" binding=\"tns:TaxCloudSoap12\">\r\n
|
724
|
-
\ <soap12:address location=\"https://
|
724
|
+
\ <soap12:address location=\"https://asmx.taxcloud.com/1.0/TaxCloud.asmx\"
|
725
725
|
/>\r\n </wsdl:port>\r\n <wsdl:port name=\"TaxCloudHttpPost\" binding=\"tns:TaxCloudHttpPost\">\r\n
|
726
|
-
\ <http:address location=\"https://
|
726
|
+
\ <http:address location=\"https://asmx.taxcloud.com/1.0/TaxCloud.asmx\"
|
727
727
|
/>\r\n </wsdl:port>\r\n </wsdl:service>\r\n</wsdl:definitions>"
|
728
728
|
http_version:
|
729
729
|
recorded_at: Thu, 09 Jan 2014 16:03:39 GMT
|
730
730
|
- request:
|
731
731
|
method: post
|
732
|
-
uri: https://
|
732
|
+
uri: https://asmx.taxcloud.com/1.0/TaxCloud.asmx
|
733
733
|
body:
|
734
734
|
encoding: UTF-8
|
735
735
|
string: <?xml version="1.0" encoding="UTF-8"?><env:Envelope xmlns:xsd="http://www.w3.org/2001/XMLSchema"
|
data/test/helper.rb
CHANGED
data/test/test_address.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'helper'
|
2
4
|
|
3
5
|
class TestAddress < TestSetup
|
@@ -43,7 +45,7 @@ class TestAddress < TestSetup
|
|
43
45
|
end
|
44
46
|
|
45
47
|
def test_verify_bad_address
|
46
|
-
e =
|
48
|
+
e = assert_raises TaxCloud::Errors::ApiError do
|
47
49
|
VCR.use_cassette('verify bad address') do
|
48
50
|
bad_address = TaxCloud::Address.new address1: '10001 Test Street', city: 'New York', state: 'New York', zip5: '99999'
|
49
51
|
bad_address.verify
|
data/test/test_cart_item.rb
CHANGED
data/test/test_client.rb
CHANGED
@@ -1,8 +1,10 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'helper'
|
2
4
|
|
3
5
|
class TestClient < TestSetup
|
4
6
|
def test_ping_with_invalid_credentials
|
5
|
-
|
7
|
+
assert_raises TaxCloud::Errors::ApiError do
|
6
8
|
VCR.use_cassette('ping_with_invalid_credentials') do
|
7
9
|
TaxCloud.client.ping
|
8
10
|
end
|
@@ -10,7 +12,7 @@ class TestClient < TestSetup
|
|
10
12
|
end
|
11
13
|
|
12
14
|
def test_ping_with_invalid_response
|
13
|
-
e =
|
15
|
+
e = assert_raises TaxCloud::Errors::UnexpectedSoapResponse do
|
14
16
|
VCR.use_cassette('ping_with_invalid_response') do
|
15
17
|
TaxCloud.client.ping
|
16
18
|
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'helper'
|
4
|
+
|
5
|
+
describe 'TaxCloud::Configuration' do
|
6
|
+
def request
|
7
|
+
TaxCloud.client.instance_variable_get('@wsdl').request
|
8
|
+
end
|
9
|
+
|
10
|
+
def reset_and_configure(options = {})
|
11
|
+
TaxCloud.reset!
|
12
|
+
TaxCloud.configure do |config|
|
13
|
+
config.api_key = 'stubbed_api_key'
|
14
|
+
config.api_login_id = 'stubbed_api_login_id'
|
15
|
+
options.each do |key, value|
|
16
|
+
config.public_send("#{key}=", value)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
describe 'open_timeout option' do
|
22
|
+
it 'has set default to 2' do
|
23
|
+
reset_and_configure
|
24
|
+
assert_equal 2, request.open_timeout
|
25
|
+
end
|
26
|
+
|
27
|
+
it 'can be changed via configuration' do
|
28
|
+
reset_and_configure(open_timeout: 3)
|
29
|
+
assert_equal 3, request.open_timeout
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
describe 'read_timeout option' do
|
34
|
+
it 'has set default to 2' do
|
35
|
+
reset_and_configure
|
36
|
+
assert_equal 2, request.read_timeout
|
37
|
+
end
|
38
|
+
|
39
|
+
it 'can be changed via configuration' do
|
40
|
+
reset_and_configure(read_timeout: 3)
|
41
|
+
assert_equal 3, request.read_timeout
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
@@ -1,12 +1,14 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'helper'
|
2
4
|
|
3
|
-
class
|
5
|
+
class TestConfigurationRequiredKeys < Minitest::Test
|
4
6
|
def setup
|
5
7
|
TaxCloud.reset!
|
6
8
|
end
|
7
9
|
|
8
10
|
def test_missing_configuration
|
9
|
-
|
11
|
+
assert_raises TaxCloud::Errors::MissingConfig do
|
10
12
|
TaxCloud.client.request :dummy, body: {}
|
11
13
|
end
|
12
14
|
end
|
@@ -15,7 +17,7 @@ class TestConfiguration < Test::Unit::TestCase
|
|
15
17
|
TaxCloud.configure do |config|
|
16
18
|
config.api_key = 'taxcloud_api_key'
|
17
19
|
end
|
18
|
-
|
20
|
+
assert_raises TaxCloud::Errors::MissingConfigOption do
|
19
21
|
TaxCloud.client.request :dummy, body: {}
|
20
22
|
end
|
21
23
|
end
|
@@ -24,7 +26,7 @@ class TestConfiguration < Test::Unit::TestCase
|
|
24
26
|
TaxCloud.configure do |config|
|
25
27
|
config.api_login_id = 'taxcloud_api_login_id'
|
26
28
|
end
|
27
|
-
|
29
|
+
assert_raises TaxCloud::Errors::MissingConfigOption do
|
28
30
|
TaxCloud.client.request :dummy, body: {}
|
29
31
|
end
|
30
32
|
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'helper'
|
4
|
+
|
5
|
+
class TestLookupResponse < TestSetup
|
6
|
+
class MockLookup < TaxCloud::Responses::Lookup
|
7
|
+
def initialize; end
|
8
|
+
end
|
9
|
+
|
10
|
+
def test_tax_amount_handles_decimal_addition_properly
|
11
|
+
response = TestLookupResponse::MockLookup.new
|
12
|
+
|
13
|
+
# `tax_amount`s chosen to provoke floating point arithmetic error
|
14
|
+
mock_savon_cart_items = [
|
15
|
+
{ cart_item_index: '0', tax_amount: '0.35' },
|
16
|
+
{ cart_item_index: '1', tax_amount: '0.7' }
|
17
|
+
]
|
18
|
+
response.cart_items = mock_savon_cart_items.map { |i| TaxCloud::Responses::CartItem.new(i) }
|
19
|
+
|
20
|
+
assert_equal 1.05, response.tax_amount
|
21
|
+
end
|
22
|
+
end
|
data/test/test_setup.rb
CHANGED
data/test/test_soap.rb
CHANGED
@@ -1,8 +1,10 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'helper'
|
2
4
|
|
3
5
|
class TestSoap < TestSetup
|
4
6
|
def test_invalid_soap_call
|
5
|
-
|
7
|
+
assert_raises Savon::UnknownOperationError do
|
6
8
|
VCR.use_cassette('invalid_soap_call') do
|
7
9
|
TaxCloud.client.request :invalid, body: {}
|
8
10
|
end
|
@@ -1,9 +1,11 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'helper'
|
2
4
|
|
3
5
|
class TestTaxCodeGroups < TestSetup
|
4
6
|
def test_all
|
5
7
|
VCR.use_cassette('get_tic_groups') do
|
6
|
-
assert TaxCloud::TaxCode::Groups.all.count
|
8
|
+
assert TaxCloud::TaxCode::Groups.all.count.positive?
|
7
9
|
end
|
8
10
|
end
|
9
11
|
|
@@ -20,7 +22,7 @@ class TestTaxCodeGroups < TestSetup
|
|
20
22
|
TaxCloud::TaxCode::Groups[TaxCloud::TaxCode::Groups::SCHOOL_RELATED_PRODUCTS]
|
21
23
|
end
|
22
24
|
VCR.use_cassette('get_tics_by_group') do
|
23
|
-
assert tax_code_group.tax_codes.count
|
25
|
+
assert tax_code_group.tax_codes.count.positive?
|
24
26
|
tax_code = tax_code_group[TaxCloud::TaxCodes::SCHOOL_INSTRUCTIONAL_MATERIAL]
|
25
27
|
assert_equal TaxCloud::TaxCodes::SCHOOL_INSTRUCTIONAL_MATERIAL, tax_code.ticid
|
26
28
|
assert_equal 'School instructional material', tax_code.description
|
data/test/test_tax_codes.rb
CHANGED
data/test/test_transaction.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'helper'
|
2
4
|
|
3
5
|
class TestTransaction < TestSetup
|
@@ -8,7 +10,7 @@ class TestTransaction < TestSetup
|
|
8
10
|
cart_items = []
|
9
11
|
cart_items << TaxCloud::CartItem.new(index: 0, item_id: 'SKU-TEST', tic: TaxCloud::TaxCodes::GENERAL, quantity: 1, price: 50.00)
|
10
12
|
cart_items << TaxCloud::CartItem.new(index: 1, item_id: 'SKU-TEST1', tic: TaxCloud::TaxCodes::GENERAL, quantity: 1, price: 100.00)
|
11
|
-
@transaction = TaxCloud::Transaction.new(customer_id: 42, cart_id: rand(
|
13
|
+
@transaction = TaxCloud::Transaction.new(customer_id: 42, cart_id: rand(18_446_744_073_709_551_616), order_id: rand(18_446_744_073_709_551_616), cart_items: cart_items, origin: origin, destination: destination)
|
12
14
|
end
|
13
15
|
|
14
16
|
def test_lookup
|
data/test/test_transaction_ny.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'helper'
|
2
4
|
|
3
5
|
class TestTransactionNy < TestSetup
|
@@ -6,7 +8,7 @@ class TestTransactionNy < TestSetup
|
|
6
8
|
origin = TaxCloud::Address.new address1: '888 6th Ave', city: 'New York', state: 'NY', zip5: '10001'
|
7
9
|
destination = TaxCloud::Address.new address1: '888 6th Ave', city: 'New York', state: 'NY', zip5: '10001'
|
8
10
|
cart_items = [TaxCloud::CartItem.new(index: 0, item_id: 'SKU-TEST', tic: TaxCloud::TaxCodes::GENERAL, quantity: 1, price: 50.00)]
|
9
|
-
@transaction = TaxCloud::Transaction.new(customer_id: 42, cart_id: 708, order_id: rand(
|
11
|
+
@transaction = TaxCloud::Transaction.new(customer_id: 42, cart_id: 708, order_id: rand(18_446_744_073_709_551_616), cart_items: cart_items, origin: origin, destination: destination)
|
10
12
|
end
|
11
13
|
|
12
14
|
def test_lookup_non_ssuta_state
|