summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorJared Norman <jared@super.gd>2019-01-23 20:51:05 -0800
committerJared Norman <jared@super.gd>2019-01-23 20:51:05 -0800
commitc371dff1fbce02e86bf1f45607f8a61f55e83b5c (patch)
treee1cbf49cbb1d130b3fa91372f2b483024d1b7968 /spec
parent8c1df35a32722bf654a7428bed4a868b90dfce4e (diff)
Handle situation where there are no line items
TaxJar API is not keen on orders with no line items and will throw errors.
Diffstat (limited to 'spec')
-rw-r--r--spec/super_good/solidus_taxjar/tax_calculator_spec.rb20
1 files changed, 20 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 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(