Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
cc875bcf
Commit
cc875bcf
authored
Oct 19, 2021
by
Vitali Tatarintev
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Resolve escalation status when incident is closed
parent
edf6df27
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
29 additions
and
1 deletion
+29
-1
app/services/issues/close_service.rb
app/services/issues/close_service.rb
+8
-0
spec/services/issues/close_service_spec.rb
spec/services/issues/close_service_spec.rb
+21
-1
No files found.
app/services/issues/close_service.rb
View file @
cc875bcf
...
...
@@ -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
...
...
spec/services/issues/close_service_spec.rb
View file @
cc875bcf
...
...
@@ -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
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment