Commit d82fa7d3 authored by rossfuhrman's avatar rossfuhrman Committed by Rémy Coutable

Fix deleting of feedback comment author

The comment author of a vulnerability feedback should be set to the
ghost user when the comment author is deleted.
parent 09bd7b18
...@@ -36,6 +36,7 @@ module EE ...@@ -36,6 +36,7 @@ module EE
has_many :assigned_epics, foreign_key: :assignee_id, class_name: "Epic" has_many :assigned_epics, foreign_key: :assignee_id, class_name: "Epic"
has_many :path_locks, dependent: :destroy # rubocop: disable Cop/ActiveRecordDependent has_many :path_locks, dependent: :destroy # rubocop: disable Cop/ActiveRecordDependent
has_many :vulnerability_feedback, foreign_key: :author_id, class_name: 'Vulnerabilities::Feedback' has_many :vulnerability_feedback, foreign_key: :author_id, class_name: 'Vulnerabilities::Feedback'
has_many :commented_vulnerability_feedback, foreign_key: :comment_author_id, class_name: 'Vulnerabilities::Feedback'
has_many :approvals, dependent: :destroy # rubocop: disable Cop/ActiveRecordDependent has_many :approvals, dependent: :destroy # rubocop: disable Cop/ActiveRecordDependent
has_many :approvers, dependent: :destroy # rubocop: disable Cop/ActiveRecordDependent has_many :approvers, dependent: :destroy # rubocop: disable Cop/ActiveRecordDependent
......
...@@ -21,6 +21,7 @@ module EE ...@@ -21,6 +21,7 @@ module EE
def migrate_vulnerabilities_feedback def migrate_vulnerabilities_feedback
user.vulnerability_feedback.update_all(author_id: ghost_user.id) user.vulnerability_feedback.update_all(author_id: ghost_user.id)
user.commented_vulnerability_feedback.update_all(comment_author_id: ghost_user.id)
end end
def migrate_reviews def migrate_reviews
......
...@@ -20,7 +20,7 @@ describe Users::MigrateToGhostUserService do ...@@ -20,7 +20,7 @@ describe Users::MigrateToGhostUserService do
end end
end end
context 'vulnerability_feedback' do context 'vulnerability_feedback author' do
let!(:user) { create(:user) } let!(:user) { create(:user) }
let(:service) { described_class.new(user) } let(:service) { described_class.new(user) }
...@@ -29,6 +29,15 @@ describe Users::MigrateToGhostUserService do ...@@ -29,6 +29,15 @@ describe Users::MigrateToGhostUserService do
end end
end end
context 'vulnerability_feedback comment author' do
let!(:user) { create(:user) }
let(:service) { described_class.new(user) }
include_examples "migrating a deleted user's associated records to the ghost user", Vulnerabilities::Feedback, [:comment_author] do
let(:created_record) { create(:vulnerability_feedback, comment_author: user) }
end
end
context 'reviews' do context 'reviews' do
let!(:user) { create(:user) } let!(:user) { create(:user) }
let(:service) { described_class.new(user) } let(:service) { described_class.new(user) }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment