diff options
-rw-r--r-- | lib/super_good/solidus_taxjar.rb | 2 | ||||
-rw-r--r-- | lib/super_good/solidus_taxjar/tax_calculator.rb | 1 | ||||
-rw-r--r-- | spec/super_good/solidus_taxjar/tax_calculator_spec.rb | 11 |
3 files changed, 14 insertions, 0 deletions
diff --git a/lib/super_good/solidus_taxjar.rb b/lib/super_good/solidus_taxjar.rb index f525ee7..82f9500 100644 --- a/lib/super_good/solidus_taxjar.rb +++ b/lib/super_good/solidus_taxjar.rb @@ -11,8 +11,10 @@ module SuperGood module SolidusTaxJar class << self attr_accessor :discount_calculator + attr_accessor :test_mode end self.discount_calculator = ::SuperGood::SolidusTaxJar::DiscountCalculator + self.test_mode = false end end diff --git a/lib/super_good/solidus_taxjar/tax_calculator.rb b/lib/super_good/solidus_taxjar/tax_calculator.rb index 54aace4..a521f0d 100644 --- a/lib/super_good/solidus_taxjar/tax_calculator.rb +++ b/lib/super_good/solidus_taxjar/tax_calculator.rb @@ -16,6 +16,7 @@ module SuperGood end def calculate + return no_tax if SuperGood::SolidusTaxJar.test_mode return no_tax if order.tax_address.empty? || order.line_items.none? cache do diff --git a/spec/super_good/solidus_taxjar/tax_calculator_spec.rb b/spec/super_good/solidus_taxjar/tax_calculator_spec.rb index b537bfc..84f9664 100644 --- a/spec/super_good/solidus_taxjar/tax_calculator_spec.rb +++ b/spec/super_good/solidus_taxjar/tax_calculator_spec.rb @@ -203,6 +203,17 @@ RSpec.describe ::SuperGood::SolidusTaxJar::TaxCalculator do end end end + + context "when test_mode is set" do + before { SuperGood::SolidusTaxJar.test_mode = true } + after { SuperGood::SolidusTaxJar.test_mode = false } + + 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 end context "and there is not a breakdown" do |