summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Todorov <chris.todorov@gmail.com>2021-03-22 11:01:59 -0700
committerGitHub <noreply@github.com>2021-03-22 11:01:59 -0700
commit535565168e47e4be6868cde9f068350417f1b1c1 (patch)
tree956802eba7bf108a0d21ad09240104cc6d392947
parent644ea96100790569379cb1b429039df71d6b62b3 (diff)
parent3b471809821fcb841e372ffaede2d8be44470a09 (diff)
Merge pull request #47 from SuperGoodSoft/forkata/fix-typo
Fix typo in address parameter helper
-rw-r--r--CHANGELOG.md4
-rw-r--r--lib/super_good/solidus_taxjar/api_params.rb2
-rw-r--r--spec/super_good/solidus_taxjar/api_params_spec.rb36
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