summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJared Norman <jared@super.gd>2019-03-14 11:12:37 -0700
committerGitHub <noreply@github.com>2019-03-14 11:12:37 -0700
commit945490776a137821df70111c32127ffc85b4c90b (patch)
treee6f6cbeccca0acb40fdef753368a255ca67e6b32
parente7682d6cd682bcff06c3a313fa0086abfc607f96 (diff)
parent828350fd2b1cab40bc05e4e47d4b20f9a8542b1f (diff)
Merge pull request #2 from JuanCrg90/bug/add-taxlocation-guard
Add guard clause for TaxLocation addresses
-rw-r--r--CHANGELOG.md3
-rw-r--r--lib/super_good/solidus_taxjar/tax_calculator.rb2
-rw-r--r--lib/super_good/solidus_taxjar/version.rb2
-rw-r--r--spec/super_good/solidus_taxjar/tax_calculator_spec.rb19
4 files changed, 25 insertions, 1 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 15069dc..2d5ded5 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,8 @@
# Changelog
+## v0.6.2
+- Updated `incomplete_address?` method to verify if a `tax_address` is a `Spree::Tax::TaxLocation`. `Spree::Tax::TaxLocation` is considered an incomplete address.
+
## v0.6.1
- Stopped using the deprecated method `Spree::Address#empty?` in favour of simply checking that we have all of the fields on the address required for doing a TaxJar lookup.
diff --git a/lib/super_good/solidus_taxjar/tax_calculator.rb b/lib/super_good/solidus_taxjar/tax_calculator.rb
index 327e248..25339ac 100644
--- a/lib/super_good/solidus_taxjar/tax_calculator.rb
+++ b/lib/super_good/solidus_taxjar/tax_calculator.rb
@@ -152,6 +152,8 @@ module SuperGood
end
def incomplete_address?(tax_address)
+ return true if tax_address.is_a?(Spree::Tax::TaxLocation)
+
[
tax_address.address1,
tax_address.city,
diff --git a/lib/super_good/solidus_taxjar/version.rb b/lib/super_good/solidus_taxjar/version.rb
index ead2b37..6ca181f 100644
--- a/lib/super_good/solidus_taxjar/version.rb
+++ b/lib/super_good/solidus_taxjar/version.rb
@@ -1,5 +1,5 @@
module SuperGood
module SolidusTaxJar
- VERSION = "0.6.1"
+ VERSION = "0.6.2"
end
end
diff --git a/spec/super_good/solidus_taxjar/tax_calculator_spec.rb b/spec/super_good/solidus_taxjar/tax_calculator_spec.rb
index 0d390ec..aaa4ce1 100644
--- a/spec/super_good/solidus_taxjar/tax_calculator_spec.rb
+++ b/spec/super_good/solidus_taxjar/tax_calculator_spec.rb
@@ -74,6 +74,25 @@ RSpec.describe ::SuperGood::SolidusTaxJar::TaxCalculator do
end
end
+ context "when the order has an incomplete tax address" do
+ let(:address) do
+ ::Spree::Address.new(
+ first_name: "Ronnie James",
+ zipcode: nil,
+ address1: nil,
+ city: "Beverly Hills",
+ state_name: "California",
+ country: ::Spree::Country.new(iso: "US")
+ )
+ end
+
+ it "returns no taxes" do
+ expect(subject.order_id).to eq order.id
+ expect(subject.shipment_taxes).to be_empty
+ expect(subject.line_item_taxes).to be_empty
+ end
+ end
+
context "when the order has no line items" do
let(:address) do
::Spree::Address.new(