diff --git a/app/models/spree/tax_rate_decorator.rb b/app/models/spree/tax_rate_decorator.rb index 80bcc450c2..121d379584 100644 --- a/app/models/spree/tax_rate_decorator.rb +++ b/app/models/spree/tax_rate_decorator.rb @@ -51,7 +51,7 @@ module Spree result = yield - # TODO: ensure + ensure self.included_in_price = old_included_in_price calculator.calculable.included_in_price = old_included_in_price diff --git a/spec/models/spree/tax_rate_spec.rb b/spec/models/spree/tax_rate_spec.rb index c10f00ac44..03b2cb39aa 100644 --- a/spec/models/spree/tax_rate_spec.rb +++ b/spec/models/spree/tax_rate_spec.rb @@ -56,6 +56,15 @@ module Spree tax_rate.included_in_price.should be_false tax_rate.calculator.calculable.included_in_price.should be_false end + + it "restores both values when an exception is raised" do + expect do + tax_rate.send(:with_tax_included_in_price) { raise Exception.new 'oops' } + end.to raise_error 'oops' + + tax_rate.included_in_price.should be_false + tax_rate.calculator.calculable.included_in_price.should be_false + end end end end