From b8dac4791bb6399f3122f1a22aff269a9ede9fea Mon Sep 17 00:00:00 2001 From: Nicholas Van Doorn Date: Wed, 24 Mar 2021 11:39:54 -0700 Subject: [PATCH 1/3] Remove unused spec variable This was not used and should be removed. Co-authored-by: Noah Silvera --- spec/super_good/solidus_taxjar/api_spec.rb | 2 -- 1 file changed, 2 deletions(-) diff --git a/spec/super_good/solidus_taxjar/api_spec.rb b/spec/super_good/solidus_taxjar/api_spec.rb index a1282a7b..61a2c86f 100644 --- a/spec/super_good/solidus_taxjar/api_spec.rb +++ b/spec/super_good/solidus_taxjar/api_spec.rb @@ -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 From 84db881c4340be3b7fa3f0ed6a80e1133a1c70fa Mon Sep 17 00:00:00 2001 From: Nicholas Van Doorn Date: Wed, 24 Mar 2021 11:43:37 -0700 Subject: [PATCH 2/3] Fix `.default_taxjar_client` In #34, we modified `.default_taxjar_client` to include the API version, and then the name of the plugin, but we also introduced a critical bug. `Taxjar::Client#set_api_config` returns a hash and not the TaxJar client, so it is not safe to chain the method call. As such, we add a spec to cover this case and patch the class method. Co-authored-by: Noah Silvera --- lib/super_good/solidus_taxjar/api.rb | 6 ++++-- spec/super_good/solidus_taxjar/api_spec.rb | 13 +++++++++++++ 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/lib/super_good/solidus_taxjar/api.rb b/lib/super_good/solidus_taxjar/api.rb index ca6ff6cc..096994b3 100644 --- a/lib/super_good/solidus_taxjar/api.rb +++ b/lib/super_good/solidus_taxjar/api.rb @@ -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) diff --git a/spec/super_good/solidus_taxjar/api_spec.rb b/spec/super_good/solidus_taxjar/api_spec.rb index 61a2c86f..94f214d9 100644 --- a/spec/super_good/solidus_taxjar/api_spec.rb +++ b/spec/super_good/solidus_taxjar/api_spec.rb @@ -17,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 } From 498036d87231bfb49fd1c3c6be9b09d0dafc7c9f Mon Sep 17 00:00:00 2001 From: Nicholas Van Doorn Date: Wed, 24 Mar 2021 11:52:39 -0700 Subject: [PATCH 3/3] Update CHANGELOG.md Co-authored-by: Noah Silvera --- CHANGELOG.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 34afe7fc..c0add7af 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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