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
merged 1 commit into from Jun 12, 2017

Conversation

Projects
None yet
3 participants
@manishrawat0212
Contributor

manishrawat0212 commented Jun 10, 2017

Issue

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.

Fix

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 { is_expected.to have_many(:payments).class_name("Spree::Payment").inverse_of(:payment_method).dependent(:restrict_with_error) }

This comment has been minimized.

@houndci-bot

houndci-bot Jun 10, 2017

Line is too long. [135/120]

@houndci-bot

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!
Details
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