Commit 78333253 authored by Luke Duncalfe's avatar Luke Duncalfe

Merge branch '330281-handle-moving-incident-to-other-project' into 'master'

Clean up pending escalations after moving incident to new project

See merge request gitlab-org/gitlab!77086
parents e42262e0 75943f4a
...@@ -10,6 +10,7 @@ module EE ...@@ -10,6 +10,7 @@ module EE
rewrite_epic_issue rewrite_epic_issue
rewrite_related_vulnerability_issues rewrite_related_vulnerability_issues
track_epic_issue_moved_from_project track_epic_issue_moved_from_project
delete_pending_escalations
super super
end end
...@@ -43,6 +44,10 @@ module EE ...@@ -43,6 +44,10 @@ module EE
issue_links = Vulnerabilities::IssueLink.for_issue(original_entity) issue_links = Vulnerabilities::IssueLink.for_issue(original_entity)
issue_links.update_all(issue_id: new_entity.id) issue_links.update_all(issue_id: new_entity.id)
end end
def delete_pending_escalations
original_entity.pending_escalations.delete_all(:delete_all)
end
end end
end end
end end
...@@ -152,4 +152,16 @@ RSpec.describe Issues::MoveService do ...@@ -152,4 +152,16 @@ RSpec.describe Issues::MoveService do
end end
end end
end end
describe '#delete_pending_escalations' do
let!(:pending_escalation) { create(:incident_management_pending_issue_escalation, issue: old_issue) }
it 'deletes the pending escalations for the incident' do
new_issue = move_service.execute(old_issue, new_project)
expect(new_issue.pending_escalations.count).to eq(0)
expect(old_issue.pending_escalations.count).to eq(0)
expect { pending_escalation.reload }.to raise_error(ActiveRecord::RecordNotFound)
end
end
end end
...@@ -259,6 +259,16 @@ RSpec.describe Issues::MoveService do ...@@ -259,6 +259,16 @@ RSpec.describe Issues::MoveService do
it_behaves_like 'copy or reset relative position' it_behaves_like 'copy or reset relative position'
end end
context 'issue with escalation status' do
it 'keeps the escalation status' do
escalation_status = create(:incident_management_issuable_escalation_status, issue: old_issue)
move_service.execute(old_issue, new_project)
expect(escalation_status.reload.issue).to eq(old_issue)
end
end
end end
describe 'move permissions' do describe 'move permissions' do
......
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