summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CHANGELOG.md5
-rw-r--r--lib/super_good/solidus_taxjar.rb4
-rw-r--r--lib/super_good/solidus_taxjar/tax_calculator.rb9
-rw-r--r--spec/super_good/solidus_taxjar/tax_calculator_spec.rb2
4 files changed, 14 insertions, 6 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
new file mode 100644
index 0000000..229a1a1
--- /dev/null
+++ b/CHANGELOG.md
@@ -0,0 +1,5 @@
+# Changelog
+
+## v0.5.0
+
+- Moved exception handler configuration to `SuperGood::SolidusTaxJar.exception_handler` from `SuperGood::SolidusTaxJar::TaxCalculator.exception_handler`. Now all the configuration options are in the same place.
diff --git a/lib/super_good/solidus_taxjar.rb b/lib/super_good/solidus_taxjar.rb
index be56453..663b3d8 100644
--- a/lib/super_good/solidus_taxjar.rb
+++ b/lib/super_good/solidus_taxjar.rb
@@ -13,9 +13,13 @@ module SuperGood
class << self
attr_accessor :discount_calculator
attr_accessor :test_mode
+ attr_accessor :exception_handler
end
self.discount_calculator = ::SuperGood::SolidusTaxJar::DiscountCalculator
self.test_mode = false
+ self.exception_handler = ->(e) {
+ Rails.logger.error "An error occurred while fetching TaxJar tax rates - #{e}: #{e.message}"
+ }
end
end
diff --git a/lib/super_good/solidus_taxjar/tax_calculator.rb b/lib/super_good/solidus_taxjar/tax_calculator.rb
index b9e6444..a3c0690 100644
--- a/lib/super_good/solidus_taxjar/tax_calculator.rb
+++ b/lib/super_good/solidus_taxjar/tax_calculator.rb
@@ -1,11 +1,6 @@
module SuperGood
module SolidusTaxJar
class TaxCalculator
- class_attribute :exception_handler
- self.exception_handler = ->(e) {
- Rails.logger.error "An error occurred while fetching TaxJar tax rates - #{e}: #{e.message}"
- }
-
def self.default_api
::SuperGood::SolidusTaxJar::API.new
end
@@ -129,6 +124,10 @@ module SuperGood
end
end
end
+
+ def exception_handler
+ SuperGood::SolidusTaxJar.exception_handler
+ end
end
end
end
diff --git a/spec/super_good/solidus_taxjar/tax_calculator_spec.rb b/spec/super_good/solidus_taxjar/tax_calculator_spec.rb
index 84f9664..e5c0a01 100644
--- a/spec/super_good/solidus_taxjar/tax_calculator_spec.rb
+++ b/spec/super_good/solidus_taxjar/tax_calculator_spec.rb
@@ -104,7 +104,7 @@ RSpec.describe ::SuperGood::SolidusTaxJar::TaxCalculator do
end
it "calls the configured error handler" do
- expect(described_class.exception_handler).to receive(:call) do |e|
+ expect(SuperGood::SolidusTaxJar.exception_handler).to receive(:call) do |e|
expect(e).to be_a StandardError
expect(e.message).to eq "A bad thing happened."
end