From cbc9db074cad3de73e6cbc8482cc34c66b022ef5 Mon Sep 17 00:00:00 2001 From: Chris Todorov Date: Mon, 15 Mar 2021 14:57:05 -0700 Subject: Add pending failing spec for address params This change adds a failing spec which exposes a typo in our API params helper method. In the next change we'll fix the issue and un-pend the spec. --- spec/super_good/solidus_taxjar/api_params_spec.rb | 37 +++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/spec/super_good/solidus_taxjar/api_params_spec.rb b/spec/super_good/solidus_taxjar/api_params_spec.rb index 0fc54f6..a86b7c6 100644 --- a/spec/super_good/solidus_taxjar/api_params_spec.rb +++ b/spec/super_good/solidus_taxjar/api_params_spec.rb @@ -362,5 +362,42 @@ RSpec.describe SuperGood::SolidusTaxjar::ApiParams do street: "475 N Beverly Dr" }) end + + context "with an address without a state" do + let(:ship_address) do + Spree::Address.create!( + address1: "72 High St", + city: "Birmingham", + country: country_uk, + first_name: "Chuck", + last_name: "Schuldiner", + phone: "1-250-555-4444", + state_name: "West Midlands", + zipcode: "B4 7TA" + ) + end + + let(:country_uk) do + Spree::Country.create!( + iso3: "GBR", + iso: "GB", + iso_name: "UNITED KINGDOM", + name: "United Kingdom", + numcode: 826, + states_required: false + ) + end + + it "uses the state_name to build address params" do + pending("fix for state name fallback") + expect(subject).to eq({ + country: "GB", + state: "West Midlands", + zip: "B4 7TA", + city: "Birmingham", + street: "72 High St" + }) + end + end end end -- cgit v1.2.3 From f994ce1c323397c74c81fb53aa7c56fdd1cbe2e0 Mon Sep 17 00:00:00 2001 From: Chris Todorov Date: Mon, 15 Mar 2021 14:59:10 -0700 Subject: Fix typo in `validate_address_params` helper This change fixes a typo in the params helper for addresses without a `state` association. This was a previously untested behaviour so we never caught this. This change also marks the failing test as no longer pending. --- lib/super_good/solidus_taxjar/api_params.rb | 2 +- spec/super_good/solidus_taxjar/api_params_spec.rb | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/lib/super_good/solidus_taxjar/api_params.rb b/lib/super_good/solidus_taxjar/api_params.rb index ebf034d..ef189e9 100644 --- a/lib/super_good/solidus_taxjar/api_params.rb +++ b/lib/super_good/solidus_taxjar/api_params.rb @@ -69,7 +69,7 @@ module SuperGood def validate_address_params(spree_address) { country: spree_address.country&.iso, - state: spree_address.state&.abbr || adddress.state_name, + state: spree_address.state&.abbr || spree_address.state_name, zip: spree_address.zipcode, city: spree_address.city, street: spree_address.address1 diff --git a/spec/super_good/solidus_taxjar/api_params_spec.rb b/spec/super_good/solidus_taxjar/api_params_spec.rb index a86b7c6..6c13e03 100644 --- a/spec/super_good/solidus_taxjar/api_params_spec.rb +++ b/spec/super_good/solidus_taxjar/api_params_spec.rb @@ -389,7 +389,6 @@ RSpec.describe SuperGood::SolidusTaxjar::ApiParams do end it "uses the state_name to build address params" do - pending("fix for state name fallback") expect(subject).to eq({ country: "GB", state: "West Midlands", -- cgit v1.2.3 From 3b471809821fcb841e372ffaede2d8be44470a09 Mon Sep 17 00:00:00 2001 From: Chris Todorov Date: Thu, 18 Mar 2021 00:45:46 -0700 Subject: Add changelog entry for bug fix This links to the PR where we fixed the issue from the changelog file, so we can know what is in the next release of the gem. --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index bbbb712..34afe7f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +## master + +- [#47](https://github.com/SuperGoodSoft/solidus_taxjar/pull/47) Fixed bug in `validate_address_params` for addresses without a state + ## v0.18.0 - [#21](https://github.com/SuperGoodSoft/solidus_taxjar/pull/21) Migrated project to `solidus_dev_support` -- cgit v1.2.3