diff --git a/app/models/solidus_avatax_certified/order_adjuster.rb b/app/models/solidus_avatax_certified/order_adjuster.rb index 52fabedc..5c1cbdbb 100644 --- a/app/models/solidus_avatax_certified/order_adjuster.rb +++ b/app/models/solidus_avatax_certified/order_adjuster.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true module SolidusAvataxCertified - class OrderAdjuster < Spree::Tax::OrderAdjuster + class OrderAdjuster < ::Spree::Tax::OrderAdjuster def adjust! if %w(cart address delivery).include?(order.state) return (order.line_items + order.shipments) diff --git a/app/models/tax_svc.rb b/app/models/tax_svc.rb index c166aacb..ede67c33 100644 --- a/app/models/tax_svc.rb +++ b/app/models/tax_svc.rb @@ -36,7 +36,10 @@ def validate_address(address) rescue StandardError => e logger.error(e) - request = { 'error' => { 'message' => e } } + request = OpenStruct.new( + success?: false, + body: { 'error' => { 'message' => e } } + ) end response = SolidusAvataxCertified::Response::AddressValidation.new(request) diff --git a/solidus_avatax_certified.gemspec b/solidus_avatax_certified.gemspec index 1ad15be3..42521496 100644 --- a/solidus_avatax_certified.gemspec +++ b/solidus_avatax_certified.gemspec @@ -28,7 +28,7 @@ Gem::Specification.new do |s| s.add_dependency 'json', '~> 2.0' s.add_dependency 'logging', '~> 2.0' s.add_dependency 'solidus', solidus_version - s.add_dependency 'solidus_support' + s.add_dependency 'solidus_support', '~> 0.3.2' s.add_development_dependency 'capybara' s.add_development_dependency 'coffee-rails' diff --git a/spec/models/tax_svc_spec.rb b/spec/models/tax_svc_spec.rb index a985ef26..6e63d1ae 100644 --- a/spec/models/tax_svc_spec.rb +++ b/spec/models/tax_svc_spec.rb @@ -69,4 +69,20 @@ expect(subject).to be_success end end + + describe '#validate_address' do + let(:address) { double(:address) } + subject(:result) { taxsvc.validate_address(address) } + + context 'when a StandardError is raised' do + before do + allow(Spree::Avatax::Config).to receive(:raise_exceptions).and_return(false) + allow(taxsvc.send(:client).addresses).to receive(:validate).and_raise(StandardError) + end + + it 'should return the response' do + expect { subject }.to_not raise_error + end + end + end end