Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix CI build and bug related to Faraday response being a hash #154

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/models/solidus_avatax_certified/order_adjuster.rb
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
5 changes: 4 additions & 1 deletion app/models/tax_svc.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion solidus_avatax_certified.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
16 changes: 16 additions & 0 deletions spec/models/tax_svc_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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