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
b348db3c
Commit
b348db3c
authored
Dec 08, 2020
by
Sarah Yasonik
Committed by
Jan Provaznik
Dec 08, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Do not auto-reapply incident label to all incidents
parent
b2a24aeb
Changes
10
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
38 additions
and
61 deletions
+38
-61
app/presenters/alert_management/alert_presenter.rb
app/presenters/alert_management/alert_presenter.rb
+1
-2
app/services/issues/base_service.rb
app/services/issues/base_service.rb
+0
-16
app/services/issues/create_service.rb
app/services/issues/create_service.rb
+16
-0
app/services/issues/update_service.rb
app/services/issues/update_service.rb
+0
-1
changelogs/unreleased/sy-allow-to-unlabel-incidents.yml
changelogs/unreleased/sy-allow-to-unlabel-incidents.yml
+5
-0
spec/mailers/emails/projects_spec.rb
spec/mailers/emails/projects_spec.rb
+2
-4
spec/services/incident_management/incidents/create_service_spec.rb
...ices/incident_management/incidents/create_service_spec.rb
+2
-0
spec/services/issues/create_service_spec.rb
spec/services/issues/create_service_spec.rb
+1
-0
spec/services/issues/update_service_spec.rb
spec/services/issues/update_service_spec.rb
+7
-36
spec/support/shared_examples/services/incident_shared_examples.rb
...port/shared_examples/services/incident_shared_examples.rb
+4
-2
No files found.
app/presenters/alert_management/alert_presenter.rb
View file @
b348db3c
...
...
@@ -8,7 +8,6 @@ module AlertManagement
MARKDOWN_LINE_BREAK
=
"
\n
"
HORIZONTAL_LINE
=
"
\n\n
---
\n\n
"
INCIDENT_LABEL_NAME
=
::
IncidentManagement
::
CreateIncidentLabelService
::
LABEL_PROPERTIES
[
:title
]
delegate
:metrics_dashboard_url
,
:runbook
,
to: :parsed_payload
...
...
@@ -48,7 +47,7 @@ module AlertManagement
end
def
incident_issues_link
project_i
ssues_url
(
project
,
label_name:
INCIDENT_LABEL_NAME
)
project_i
ncidents_url
(
project
)
end
def
performance_dashboard_link
...
...
app/services/issues/base_service.rb
View file @
b348db3c
...
...
@@ -73,22 +73,6 @@ module Issues
Milestones
::
IssuesCountService
.
new
(
milestone
).
delete_cache
end
# Applies label "incident" (creates it if missing) to incident issues.
# Please use in "after" hooks only to ensure we are not appyling
# labels prematurely.
def
add_incident_label
(
issue
)
return
unless
issue
.
incident?
label
=
::
IncidentManagement
::
CreateIncidentLabelService
.
new
(
project
,
current_user
)
.
execute
.
payload
[
:label
]
return
if
issue
.
label_ids
.
include?
(
label
.
id
)
issue
.
labels
<<
label
end
end
end
...
...
app/services/issues/create_service.rb
View file @
b348db3c
...
...
@@ -49,6 +49,22 @@ module Issues
def
user_agent_detail_service
UserAgentDetailService
.
new
(
@issue
,
@request
)
end
# Applies label "incident" (creates it if missing) to incident issues.
# For use in "after" hooks only to ensure we are not appyling
# labels prematurely.
def
add_incident_label
(
issue
)
return
unless
issue
.
incident?
label
=
::
IncidentManagement
::
CreateIncidentLabelService
.
new
(
project
,
current_user
)
.
execute
.
payload
[
:label
]
return
if
issue
.
label_ids
.
include?
(
label
.
id
)
issue
.
labels
<<
label
end
end
end
...
...
app/services/issues/update_service.rb
View file @
b348db3c
...
...
@@ -34,7 +34,6 @@ module Issues
end
def
after_update
(
issue
)
add_incident_label
(
issue
)
IssuesChannel
.
broadcast_to
(
issue
,
event:
'updated'
)
if
Gitlab
::
ActionCable
::
Config
.
in_app?
||
Feature
.
enabled?
(
:broadcast_issue_updates
,
issue
.
project
)
end
...
...
changelogs/unreleased/sy-allow-to-unlabel-incidents.yml
0 → 100644
View file @
b348db3c
---
title
:
Do not automatically reapply incident label after user removes it
merge_request
:
49188
author
:
type
:
fixed
spec/mailers/emails/projects_spec.rb
View file @
b348db3c
...
...
@@ -19,11 +19,9 @@ RSpec.describe Emails::Projects do
create
(
:project_incident_management_setting
,
project:
project
,
create_issue:
true
)
end
let
(
:incident_issues_url
)
do
project_issues_url
(
project
,
label_name:
'incident'
)
end
let
(
:incidents_url
)
{
project_incidents_url
(
project
)
}
it
{
is_expected
.
to
have_body_text
(
incident
_issue
s_url
)
}
it
{
is_expected
.
to
have_body_text
(
incidents_url
)
}
end
end
...
...
spec/services/incident_management/incidents/create_service_spec.rb
View file @
b348db3c
...
...
@@ -37,6 +37,8 @@ RSpec.describe IncidentManagement::Incidents::CreateService do
end
let
(
:issue
)
{
new_issue
}
include_examples
'has incident label'
end
context
'with default severity'
do
...
...
spec/services/issues/create_service_spec.rb
View file @
b348db3c
...
...
@@ -63,6 +63,7 @@ RSpec.describe Issues::CreateService do
subject
{
issue
}
it_behaves_like
'incident issue'
it_behaves_like
'has incident label'
it_behaves_like
'an incident management tracked event'
,
:incident_management_incident_created
it
'does create an incident label'
do
...
...
spec/services/issues/update_service_spec.rb
View file @
b348db3c
...
...
@@ -99,31 +99,18 @@ RSpec.describe Issues::UpdateService, :mailer do
context
'when issue type is incident'
do
let
(
:issue
)
{
create
(
:incident
,
project:
project
)
}
it
'changes updates the severity'
do
before
do
update_issue
(
opts
)
expect
(
issue
.
severity
).
to
eq
(
'low'
)
end
it_behaves_like
'incident issue'
do
before
do
update_issue
(
opts
)
end
end
context
'with existing incident label'
do
let_it_be
(
:incident_label
)
{
create
(
:label
,
:incident
,
project:
project
)
}
it_behaves_like
'incident issue'
before
do
opts
.
delete
(
:label_ids
)
# don't override but retain existing labels
issue
.
labels
<<
incident_label
end
it
'changes updates the severity'
do
expect
(
issue
.
severity
).
to
eq
(
'low'
)
end
it_behaves_like
'incident issue'
do
before
do
update_issue
(
opts
)
end
end
it
'does not apply incident labels'
do
expect
(
issue
.
labels
).
to
match_array
[
label
]
end
end
...
...
@@ -155,7 +142,6 @@ RSpec.describe Issues::UpdateService, :mailer do
context
'issue in incident type'
do
let
(
:current_user
)
{
user
}
let
(
:incident_label_attributes
)
{
attributes_for
(
:label
,
:incident
)
}
before
do
opts
.
merge!
(
issue_type:
'incident'
,
confidential:
true
)
...
...
@@ -170,21 +156,6 @@ RSpec.describe Issues::UpdateService, :mailer do
subject
end
end
it
'does create an incident label'
do
expect
{
subject
}
.
to
change
{
Label
.
where
(
incident_label_attributes
).
count
}.
by
(
1
)
end
context
'when invalid'
do
before
do
opts
.
merge!
(
title:
''
)
end
it
'does not create an incident label prematurely'
do
expect
{
subject
}.
not_to
change
(
Label
,
:count
)
end
end
end
it
'updates open issue counter for assignees when issue is reassigned'
do
...
...
spec/support/shared_examples/services/incident_shared_examples.rb
View file @
b348db3c
...
...
@@ -11,11 +11,13 @@
#
# include_examples 'incident issue'
RSpec
.
shared_examples
'incident issue'
do
let
(
:label_properties
)
{
attributes_for
(
:label
,
:incident
)
}
it
'has incident as issue type'
do
expect
(
issue
.
issue_type
).
to
eq
(
'incident'
)
end
end
RSpec
.
shared_examples
'has incident label'
do
let
(
:label_properties
)
{
attributes_for
(
:label
,
:incident
)
}
it
'has exactly one incident label'
do
expect
(
issue
.
labels
).
to
be_one
do
|
label
|
...
...
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