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 critical bug in API class #52

Merged
merged 3 commits into from
Mar 24, 2021
Merged
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
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,13 @@

## master

[#52](https://github.com/supergoodsoft/solidus_taxjar/pull/52) fixes a critical bug in the API class that was released in `v0.18.0`. Please upgrade.

- [#47](https://github.com/SuperGoodSoft/solidus_taxjar/pull/47) Fixed bug in `validate_address_params` for addresses without a state
- [#52](https://github.com/supergoodsoft/solidus_taxjar/pull/52) Fixed critical bug in API class

## v0.18.0
## ~~v0.18.0~~
`v0.18.0` was removed due to a regression in the API class that was fixed in [#52](https://github.com/SuperGoodSoft/solidus_taxjar/pull/52) and `v0.18.1`

- [#21](https://github.com/SuperGoodSoft/solidus_taxjar/pull/21) Migrated project to `solidus_dev_support`
- [#22](https://github.com/SuperGoodSoft/solidus_taxjar/pull/22) Added support for TaxJar address validation API through `SuperGood::SolidusTaxJar::Addresses` class
Expand Down
6 changes: 4 additions & 2 deletions lib/super_good/solidus_taxjar/api.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,15 @@ module SuperGood
module SolidusTaxjar
class Api
def self.default_taxjar_client
::Taxjar::Client.new(
client = ::Taxjar::Client.new(
api_key: ENV.fetch("TAXJAR_API_KEY"),
api_url: ENV.fetch("TAXJAR_API_URL") { "https://api.taxjar.com" } # Sandbox URL: https://api.sandbox.taxjar.com
).set_api_config('headers', {
)
client.set_api_config('headers', {
'x-api-version' => '2020-08-07',
'plugin' => 'supergoodsolidustaxjar'
})
client
end

def initialize(taxjar_client: self.class.default_taxjar_client)
Expand Down
15 changes: 13 additions & 2 deletions spec/super_good/solidus_taxjar/api_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
describe ".new" do
subject { described_class.new }

let(:dummy_client) { instance_double ::Taxjar::Client }

before do
ENV["TAXJAR_API_KEY"] = 'taxjar_api_token'
end
Expand All @@ -19,6 +17,19 @@
end
end

describe ".default_taxjar_client" do
subject { described_class.default_taxjar_client }

before do
ENV["TAXJAR_API_KEY"] = 'taxjar_api_token'
end

it "returns an instance of the TaxJar client" do
expect(subject).to be_an_instance_of(::Taxjar::Client)
end
end


describe "#tax_for" do
subject { api.tax_for order }

Expand Down