mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-04-01 06:41:41 +00:00
with_tax_included_in_price handles exceptions gracefully
This commit is contained in:
@@ -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
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user