Commit cc875bcf authored by Vitali Tatarintev's avatar Vitali Tatarintev

Resolve escalation status when incident is closed

parent edf6df27
......@@ -62,6 +62,7 @@ module Issues
def perform_incident_management_actions(issue)
resolve_alert(issue)
resolve_incident(issue)
end
def close_external_issue(issue, closed_via)
......@@ -91,6 +92,13 @@ module Issues
end
end
def resolve_incident(issue)
return unless issue.incident?
status = issue.incident_management_issuable_escalation_status || issue.build_incident_management_issuable_escalation_status
status.resolve
end
def store_first_mentioned_in_commit_at(issue, merge_request, max_commit_lookup: 100)
metrics = issue.metrics
return if metrics.nil? || metrics.first_mentioned_in_commit_at
......
......@@ -83,6 +83,10 @@ RSpec.describe Issues::CloseService do
service.execute(issue)
end
it 'does not change escalation status' do
expect { service.execute(issue) }.not_to change { IncidentManagement::IssuableEscalationStatus.where(issue: issue).count }
end
context 'issue is incident type' do
let(:issue) { create(:incident, project: project) }
let(:current_user) { user }
......@@ -90,6 +94,22 @@ RSpec.describe Issues::CloseService do
subject { service.execute(issue) }
it_behaves_like 'an incident management tracked event', :incident_management_incident_closed
it 'creates a new escalation resolved escalation status', :aggregate_failures do
expect { service.execute(issue) }.to change { IncidentManagement::IssuableEscalationStatus.where(issue: issue).count }.to(1)
expect(issue.incident_management_issuable_escalation_status).to be_resolved
end
context 'when there is an escalation status' do
before do
create(:incident_management_issuable_escalation_status, issue: issue)
end
it 'changes escalations status to resolved' do
expect { service.execute(issue) }.to change { issue.incident_management_issuable_escalation_status.reload.resolved? }.to(true)
end
end
end
end
......@@ -237,7 +257,7 @@ RSpec.describe Issues::CloseService do
it 'verifies the number of queries' do
recorded = ActiveRecord::QueryRecorder.new { close_issue }
expected_queries = 27
expected_queries = 32
expect(recorded.count).to be <= expected_queries
expect(recorded.cached_count).to eq(0)
......
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