Destroy dependent notifications of a collection (#39429)

This commit is contained in:
David Roetzel
2026-06-15 17:01:10 +02:00
committed by Claire
parent fcf222246a
commit dc53b0e077
3 changed files with 17 additions and 1 deletions
+1
View File
@@ -33,6 +33,7 @@ class Collection < ApplicationRecord
has_many :accepted_collection_items, -> { accepted }, class_name: 'CollectionItem', inverse_of: :collection # rubocop:disable Rails/HasManyOrHasOneDependent
has_many :collection_reports, dependent: :delete_all
has_many :accounts, -> { merge(CollectionItem.pending_or_accepted) }, through: :collection_items
has_many :notifications, as: :activity, dependent: :destroy
validates :name, presence: true
validates :name, length: { maximum: 40 }, if: :local?
+1 -1
View File
@@ -136,7 +136,7 @@ class Notification < ApplicationRecord
belongs_to :generated_annual_report, inverse_of: false
belongs_to :quote, inverse_of: :notification
belongs_to :collection_item, inverse_of: false # TODO: have an inverse?
belongs_to :collection, inverse_of: false # TODO: have an inverse?
belongs_to :collection, inverse_of: :notifications
end
validates :type, inclusion: { in: TYPES }