summaryrefslogtreecommitdiff
path: root/spec/super_good/solidus_taxjar/tax_calculator_spec.rb
diff options
context:
space:
mode:
authorJuan Carlos Ruiz <JuanCrg90@gmail.com>2019-03-13 12:41:45 -0600
committerJuan Carlos Ruiz <JuanCrg90@gmail.com>2019-03-14 11:21:11 -0600
commitfc370fa9d6a6f33cf71508f3462e9978a68da53d (patch)
tree35c0c7d9705140c4635d15b083d8247e827d70e4 /spec/super_good/solidus_taxjar/tax_calculator_spec.rb
parente7682d6cd682bcff06c3a313fa0086abfc607f96 (diff)
Add guard clause for TaxLocation addresses
From Solidus Documentation: An order's tax_address can – through duck typing – be a Spree::TaxLocation instead of the shipping address. This adds a guard clause that validates if the tax_address is a TaxLocation, in this case we know that the address is incomplete.
Diffstat (limited to 'spec/super_good/solidus_taxjar/tax_calculator_spec.rb')
-rw-r--r--spec/super_good/solidus_taxjar/tax_calculator_spec.rb19
1 files changed, 19 insertions, 0 deletions
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(