From 82b7f6519d736a5c825a674551613ac44876bb7c Mon Sep 17 00:00:00 2001 From: Andy Zhao <17884966+Zhao-Andy@users.noreply.github.com> Date: Thu, 4 Feb 2021 14:41:17 -0500 Subject: [PATCH] Delete all notifications instead of destroying (#12577) * Delete all notifications instead of destroying * Update spec to match new association --- app/models/organization.rb | 2 +- spec/models/organization_spec.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/models/organization.rb b/app/models/organization.rb index a8e3693c7..62812ab15 100644 --- a/app/models/organization.rb +++ b/app/models/organization.rb @@ -27,7 +27,7 @@ class Organization < ApplicationRecord has_many :credits, dependent: :restrict_with_error has_many :display_ads, dependent: :destroy has_many :listings, dependent: :destroy - has_many :notifications, dependent: :destroy + has_many :notifications, dependent: :delete_all has_many :organization_memberships, dependent: :delete_all has_many :profile_pins, as: :profile, inverse_of: :profile, dependent: :destroy has_many :sponsorships, dependent: :destroy diff --git a/spec/models/organization_spec.rb b/spec/models/organization_spec.rb index 91ef38ec0..947f80551 100644 --- a/spec/models/organization_spec.rb +++ b/spec/models/organization_spec.rb @@ -12,7 +12,7 @@ RSpec.describe Organization, type: :model do it { is_expected.to have_many(:credits).dependent(:restrict_with_error) } it { is_expected.to have_many(:display_ads).dependent(:destroy) } it { is_expected.to have_many(:listings).dependent(:destroy) } - it { is_expected.to have_many(:notifications).dependent(:destroy) } + it { is_expected.to have_many(:notifications).dependent(:delete_all) } it { is_expected.to have_many(:organization_memberships).dependent(:delete_all) } it { is_expected.to have_many(:profile_pins).dependent(:destroy) } it { is_expected.to have_many(:sponsorships).dependent(:destroy) }