summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/super_good/solidus_taxjar/tax_calculator.rb2
-rw-r--r--spec/super_good/solidus_taxjar/tax_calculator_spec.rb20
2 files changed, 21 insertions, 1 deletions
diff --git a/lib/super_good/solidus_taxjar/tax_calculator.rb b/lib/super_good/solidus_taxjar/tax_calculator.rb
index 474f762..0b02569 100644
--- a/lib/super_good/solidus_taxjar/tax_calculator.rb
+++ b/lib/super_good/solidus_taxjar/tax_calculator.rb
@@ -16,7 +16,7 @@ module SuperGood
end
def calculate
- return no_tax if order.tax_address.empty?
+ return no_tax if order.tax_address.empty? || order.line_items.none?
cache do
next no_tax unless taxjar_breakdown
diff --git a/spec/super_good/solidus_taxjar/tax_calculator_spec.rb b/spec/super_good/solidus_taxjar/tax_calculator_spec.rb
index 87d30c4..b537bfc 100644
--- a/spec/super_good/solidus_taxjar/tax_calculator_spec.rb
+++ b/spec/super_good/solidus_taxjar/tax_calculator_spec.rb
@@ -15,6 +15,7 @@ RSpec.describe ::SuperGood::SolidusTaxJar::TaxCalculator do
id: 10,
store: store,
ship_address: address,
+ line_items: line_items,
shipments: [
boring_shipment,
shipment_with_adjustment,
@@ -23,6 +24,8 @@ RSpec.describe ::SuperGood::SolidusTaxJar::TaxCalculator do
)
end
+ let(:line_items) { [::Spree::LineItem.new] }
+
let(:boring_shipment) do
::Spree::Shipment.new(id: 1, cost: 7)
end
@@ -71,6 +74,23 @@ RSpec.describe ::SuperGood::SolidusTaxJar::TaxCalculator do
end
end
+ context "when the order has no line items" do
+ let(:address) do
+ ::Spree::Address.new(
+ first_name: "Ronnie James",
+ country: ::Spree::Country.new(iso: "US")
+ )
+ end
+
+ let(:line_items) { [] }
+
+ 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 API encounters an error" do
let(:address) do
::Spree::Address.new(