From 7e595fef729f15603acc749d57d3493267560365 Mon Sep 17 00:00:00 2001 From: smriti Date: Mon, 22 Sep 2025 18:46:29 +0530 Subject: [PATCH] Added dependent destroy clause for notification_settings --- app/models/user.rb | 2 +- spec/models/user_spec.rb | 1 + spec/support/shared_examples/models/user_shared_examples.rb | 1 - 3 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/models/user.rb b/app/models/user.rb index 5a02462482eb0d..752a399b99a2a4 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -257,7 +257,7 @@ def update_tracked_fields!(request) has_many :pipeline_schedules, foreign_key: :owner_id, class_name: 'Ci::PipelineSchedule' has_many :todos, dependent: :delete_all # rubocop:disable Cop/ActiveRecordDependent -- legacy behavior has_many :authored_todos, class_name: 'Todo', dependent: :destroy, foreign_key: :author_id # rubocop:disable Cop/ActiveRecordDependent - has_many :notification_settings + has_many :notification_settings, dependent: :destroy # rubocop:disable Cop/ActiveRecordDependent has_many :award_emoji, dependent: :destroy # rubocop:disable Cop/ActiveRecordDependent has_many :triggers, -> { Feature.enabled?(:trigger_token_expiration) ? not_expired : self }, class_name: 'Ci::Trigger', foreign_key: :owner_id has_many :audit_events, foreign_key: :author_id, inverse_of: :user diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb index 26a9bd348f7963..7db1674aef9426 100644 --- a/spec/models/user_spec.rb +++ b/spec/models/user_spec.rb @@ -242,6 +242,7 @@ it { is_expected.to have_many(:events).dependent(:delete_all) } it { is_expected.to have_many(:issues).dependent(:destroy) } it { is_expected.to have_many(:notes).dependent(:destroy) } + it { is_expected.to have_many(:notification_settings).dependent(:destroy) } it { is_expected.to have_many(:merge_requests).dependent(:destroy) } it { is_expected.to have_many(:identities).dependent(:destroy) } it { is_expected.to have_many(:spam_logs).dependent(:destroy) } diff --git a/spec/support/shared_examples/models/user_shared_examples.rb b/spec/support/shared_examples/models/user_shared_examples.rb index f0cdab91954d2c..88be331cd3563b 100644 --- a/spec/support/shared_examples/models/user_shared_examples.rb +++ b/spec/support/shared_examples/models/user_shared_examples.rb @@ -31,7 +31,6 @@ builds pipelines pipeline_schedules - notification_settings triggers audit_events uploaded_uploads -- GitLab