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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Restrict deletion of payment method if associated with payments or credit cards #8055

merged 1 commit into from Jun 12, 2017


None yet
3 participants

manishrawat0212 commented Jun 10, 2017


Admin can delete a payment method which has associated payments or credit cards.
This removes the :payment_method_id from the existing payments and credit cards objects, which leads to inconsistencies.


dependent: :restrict_with_error option should be used in the associations.

@@ -1,6 +1,11 @@
require 'spec_helper'
describe Spree::PaymentMethod, type: :model do
describe "Associations" do
it { have_many(:payments).class_name("Spree::Payment").inverse_of(:payment_method).dependent(:restrict_with_error) }

This comment has been minimized.


houndci-bot Jun 10, 2017

Line is too long. [135/120]


houndci-bot Jun 10, 2017

Line is too long. [135/120]

@damianlegawiec damianlegawiec merged commit df9ea95 into spree:master Jun 12, 2017

2 checks passed

ci/circleci Your tests passed on CircleCI!
hound 1 violation found.

@manishrawat0212 manishrawat0212 deleted the manishrawat0212:payment_method_association_fixes branch Jun 23, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment