summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicholas Van Doorn <nick@super.gd>2021-03-24 13:21:14 -0700
committerGitHub <noreply@github.com>2021-03-24 13:21:14 -0700
commit236689547619b00c5822a745fe5b739932425bcf (patch)
tree432d1a0d9b74da60dfb3ffc305260f79ac5a563b
parent535565168e47e4be6868cde9f068350417f1b1c1 (diff)
parent498036d87231bfb49fd1c3c6be9b09d0dafc7c9f (diff)
Merge pull request #52 from nvandoorn/fix-bug-in-api-class
Fix critical bug in API class
-rw-r--r--CHANGELOG.md6
-rw-r--r--lib/super_good/solidus_taxjar/api.rb6
-rw-r--r--spec/super_good/solidus_taxjar/api_spec.rb15
3 files changed, 22 insertions, 5 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 34afe7f..c0add7a 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
diff --git a/lib/super_good/solidus_taxjar/api.rb b/lib/super_good/solidus_taxjar/api.rb
index ca6ff6c..096994b 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 a1282a7..94f214d 100644
--- a/spec/super_good/solidus_taxjar/api_spec.rb
+++ b/spec/super_good/solidus_taxjar/api_spec.rb
@@ -4,8 +4,6 @@ RSpec.describe SuperGood::SolidusTaxjar::Api do
describe ".new" do
subject { described_class.new }
- let(:dummy_client) { instance_double ::Taxjar::Client }
-
before do
ENV["TAXJAR_API_KEY"] = 'taxjar_api_token'
end
@@ -19,6 +17,19 @@ RSpec.describe SuperGood::SolidusTaxjar::Api do
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 }