diff options
-rw-r--r-- | CHANGELOG.md | 4 | ||||
-rw-r--r-- | lib/super_good/solidus_taxjar/api_params.rb | 2 | ||||
-rw-r--r-- | spec/super_good/solidus_taxjar/api_params_spec.rb | 36 |
3 files changed, 41 insertions, 1 deletions
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` 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 0fc54f6..6c13e03 100644 --- a/spec/super_good/solidus_taxjar/api_params_spec.rb +++ b/spec/super_good/solidus_taxjar/api_params_spec.rb @@ -362,5 +362,41 @@ 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 + expect(subject).to eq({ + country: "GB", + state: "West Midlands", + zip: "B4 7TA", + city: "Birmingham", + street: "72 High St" + }) + end + end end end |