Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes for discard 1.1.0 #3202

Merged
merged 2 commits into from May 9, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 2 additions & 1 deletion core/app/models/spree/store_credit.rb
Expand Up @@ -39,7 +39,7 @@ class Spree::StoreCredit < Spree::PaymentSource
before_validation :associate_credit_type
before_validation :validate_category_unchanged, on: :update
before_destroy :validate_no_amount_used
validate :validate_no_amount_used, if: :discarded?
before_discard :validate_no_amount_used

attr_accessor :action, :action_amount, :action_originator, :action_authorization_code, :store_credit_reason

Expand Down 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