From 8912e81c695ec1aafe3fdb03203d31fdee71e9a6 Mon Sep 17 00:00:00 2001 From: Jared Norman Date: Sun, 20 Jan 2019 13:29:46 -0800 Subject: Improve tax handling This is partially a refactor, and also handles the unlikely scenario where there is a shipping tax, but no breakdown. --- spec/super_good/solidus_taxjar/tax_calculator_spec.rb | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'spec/super_good') diff --git a/spec/super_good/solidus_taxjar/tax_calculator_spec.rb b/spec/super_good/solidus_taxjar/tax_calculator_spec.rb index 19841a8..b97f53b 100644 --- a/spec/super_good/solidus_taxjar/tax_calculator_spec.rb +++ b/spec/super_good/solidus_taxjar/tax_calculator_spec.rb @@ -79,12 +79,12 @@ RSpec.describe ::SuperGood::SolidusTaxJar::TaxCalculator do instance_double( ::Taxjar::Tax, breakdown: breakdown, - shipping: 10.0 + shipping: shipping_tax ) ) end - context "and there is a breakdown" do + context "and there is tax" do let!(:tax_rate) do ::Spree::TaxRate.create!( name: "Sales Tax", @@ -93,6 +93,8 @@ RSpec.describe ::SuperGood::SolidusTaxJar::TaxCalculator do ) end + let(:shipping_tax) { 10 } + let(:breakdown) do instance_double ::Taxjar::Breakdown, line_items: [taxjar_line_item] end @@ -141,6 +143,7 @@ RSpec.describe ::SuperGood::SolidusTaxJar::TaxCalculator do context "and there is not a breakdown" do let(:breakdown) { nil } + let(:shipping_tax) { 0 } it "returns no taxes" do expect(subject.order_id).to eq order.id -- cgit v1.2.3