OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub
Ruby agile-developmentangularbcfboardsbug-trackerganttgantt-chartifcissue-trackerjira-alternativekanbanopenprojectproduct-managementproject-managementproject-planningroadmaprubyscrumtimelineworkflows
bug/61756 Cannot delete users who have work package reminders (#18067)
Kabiru Mwenjaf2c12315e6e4
diff --git a/app/models/reminder_notification.rb b/app/models/reminder_notification.rbindex c005f39a6ee..aae31fac943 100644--- a/app/models/reminder_notification.rb+++ b/app/models/reminder_notification.rb@@ -28,5 +28,5 @@class ReminderNotification < ApplicationRecordbelongs_to :reminder- belongs_to :notification, dependent: :destroy+ belongs_to :notificationenddiff --git a/app/models/user.rb b/app/models/user.rbindex 88bbc9b697b..3be73675a2c 100644--- a/app/models/user.rb+++ b/app/models/user.rb@@ -92,6 +92,7 @@ class User < Principaldependent: :destroyhas_many :emoji_reactions, dependent: :destroy+ has_many :reminders, foreign_key: "creator_id", dependent: :destroy, inverse_of: :creatorhas_many :remote_identities, dependent: :destroy# Users blocked via brute force preventiondiff --git a/app/workers/principals/delete_job.rb b/app/workers/principals/delete_job.rbindex 60a2c5fa2d7..218b5767c2b 100644--- a/app/workers/principals/delete_job.rb+++ b/app/workers/principals/delete_job.rb@@ -70,6 +70,10 @@ class Principals::DeleteJob < ApplicationJobenddef delete_notifications(principal)+ ::ReminderNotification.joins(:notification)+ .where(notifications: { recipient: principal })+ .delete_all+::Notification.where(recipient: principal).delete_allenddiff --git a/spec/models/reminder_notification_spec.rb b/spec/models/reminder_notification_spec.rbindex d079c49aae0..708107c36c7 100644--- a/spec/models/reminder_notification_spec.rb+++ b/spec/models/reminder_notification_spec.rb@@ -1,3 +1,5 @@+# frozen_string_literal: true+#-- copyright# OpenProject is an open source project management software.# Copyright (C) the OpenProject GmbH@@ -31,6 +33,6 @@ require "spec_helper"RSpec.describe ReminderNotification dodescribe "Associations" doit { is_expected.to belong_to(:reminder) }- it { is_expected.to belong_to(:notification).dependent(:destroy) }+ it { is_expected.to belong_to(:notification) }endenddiff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rbindex 884b7dfd8d5..dc403a5400f 100644--- a/spec/models/user_spec.rb+++ b/spec/models/user_spec.rb@@ -49,6 +49,7 @@ RSpec.describe User dodescribe "Associations" doit { is_expected.to have_many(:emoji_reactions).dependent(:destroy) }+ it { is_expected.to have_many(:reminders).with_foreign_key(:creator_id).dependent(:destroy).inverse_of(:creator) }enddescribe "with long but allowed attributes" do