Skip to content

Commit

Permalink
Ensure callback chain is aborted when store credit is not valid
Browse files Browse the repository at this point in the history
This is needed to avoid discard to set deleted_at anyway.

Now that we are not running this method as a validation anymore we need
to stop the callback chain by throwing abort, see:

https://api.rubyonrails.org/classes/ActiveModel/Callbacks.html
  • Loading branch information
kennyadsl committed May 7, 2019
1 parent cad7e25 commit 892e5dc
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions core/app/models/spree/store_credit.rb
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,7 @@ def validate_category_unchanged
def validate_no_amount_used
if amount_used > 0
errors.add(:amount_used, 'is greater than zero. Can not delete store credit')
throw :abort
end
end

Expand Down

0 comments on commit 892e5dc

Please sign in to comment.