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
1ebbf2cb
Commit
1ebbf2cb
authored
Oct 24, 2019
by
Vitali Tatarintev
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add IID to a generic alert issue title
https://gitlab.com/gitlab-org/gitlab/issues/34687
parent
7f936a16
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
73 additions
and
0 deletions
+73
-0
ee/app/models/ee/issue.rb
ee/app/models/ee/issue.rb
+23
-0
ee/spec/models/issue_spec.rb
ee/spec/models/issue_spec.rb
+50
-0
No files found.
ee/app/models/ee/issue.rb
View file @
1ebbf2cb
...
...
@@ -33,6 +33,8 @@ module EE
has_many
:prometheus_alerts
,
through: :prometheus_alert_events
validates
:weight
,
allow_nil:
true
,
numericality:
{
greater_than_or_equal_to:
0
}
after_create
:update_generic_alert_issue_if_applicable
end
class_methods
do
...
...
@@ -129,5 +131,26 @@ module EE
[
WEIGHT_NONE
]
+
WEIGHT_RANGE
.
to_a
end
end
private
def
update_generic_alert_issue_if_applicable
return
unless
has_default_generic_alert_title?
&&
alerts_service_activated?
update_column
(
:title
,
"
#{
title
}
#{
id
}
"
)
end
def
has_default_generic_alert_title?
title
==
::
Gitlab
::
Alerting
::
NotificationPayloadParser
::
DEFAULT_TITLE
end
def
incident_management_available?
project
.
feature_available?
(
:incident_management
)
end
def
alerts_service_activated?
incident_management_available?
&&
project
.
alerts_service
.
try
(
:active?
)
end
end
end
ee/spec/models/issue_spec.rb
View file @
1ebbf2cb
...
...
@@ -7,6 +7,56 @@ describe Issue do
using
RSpec
::
Parameterized
::
TableSyntax
context
'callbacks'
do
describe
'.after_create'
do
set
(
:project
)
{
create
(
:project
)
}
context
'when issue title is "New: Incident"'
do
let
(
:issue
)
{
build
(
:issue
,
project:
project
,
title:
'New: Incident'
)
}
context
'when incident management available'
do
before
do
stub_licensed_features
(
incident_management:
true
)
end
context
'when alerts service is active'
do
let!
(
:alerts_service
)
{
create
(
:alerts_service
,
project:
project
)
}
it
'updates issue title with the IID'
do
issue
.
save
expect
(
issue
.
reload
.
title
).
to
eq
(
"New: Incident
#{
issue
.
id
}
"
)
end
end
context
'when alerts service is not active'
do
it
'does not change issue title'
do
expect
{
issue
.
save
}.
not_to
change
{
issue
.
title
}
end
end
end
context
'when incident management is not available'
do
before
do
stub_licensed_features
(
incident_management:
false
)
end
it
'does not change issue title'
do
expect
{
issue
.
save
}.
not_to
change
{
issue
.
title
}
end
end
end
context
'when issue title is not "New: Incident"'
do
let
(
:issue
)
{
build
(
:issue
,
project:
project
,
title:
'Not New: Incident'
)
}
it
'does not change issue title'
do
expect
{
issue
.
save
}.
not_to
change
{
issue
.
title
}
end
end
end
end
context
'scopes'
do
describe
'.service_desk'
do
it
'returns the service desk issue'
do
...
...
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