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
a3c8856e
Commit
a3c8856e
authored
Oct 24, 2019
by
Vitali Tatarintev
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Check if the issue created by Alert Bot
Update issue title only if it was created by Alert Bot
parent
6d549a2c
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
22 additions
and
11 deletions
+22
-11
ee/app/models/ee/issue.rb
ee/app/models/ee/issue.rb
+7
-7
ee/spec/models/issue_spec.rb
ee/spec/models/issue_spec.rb
+15
-4
No files found.
ee/app/models/ee/issue.rb
View file @
a3c8856e
...
...
@@ -34,7 +34,7 @@ module EE
validates
:weight
,
allow_nil:
true
,
numericality:
{
greater_than_or_equal_to:
0
}
after_create
:update_generic_alert_
issu
e_if_applicable
after_create
:update_generic_alert_
titl
e_if_applicable
end
class_methods
do
...
...
@@ -134,14 +134,14 @@ module EE
private
def
update_generic_alert_issue_if_applicable
return
unless
has_default_generic_alert_title?
&&
project
.
alerts_service_activated?
update_column
(
:title
,
"
#{
title
}
#{
id
}
"
)
def
update_generic_alert_title_if_applicable
update_column
(
:title
,
"
#{
title
}
#{
id
}
"
)
if
generic_alert_with_default_title?
end
def
has_default_generic_alert_title?
title
==
::
Gitlab
::
Alerting
::
NotificationPayloadParser
::
DEFAULT_TITLE
def
generic_alert_with_default_title?
title
==
::
Gitlab
::
Alerting
::
NotificationPayloadParser
::
DEFAULT_TITLE
&&
project
.
alerts_service_activated?
&&
author
==
::
User
.
alert_bot
end
end
end
ee/spec/models/issue_spec.rb
View file @
a3c8856e
...
...
@@ -10,19 +10,30 @@ describe Issue do
context
'callbacks'
do
describe
'.after_create'
do
set
(
:project
)
{
create
(
:project
)
}
let
(
:author
)
{
User
.
alert_bot
}
context
'when issue title is "New: Incident"'
do
let
(
:issue
)
{
build
(
:issue
,
project:
project
,
title:
'New: Incident'
)
}
let
(
:issue
)
{
build
(
:issue
,
project:
project
,
author:
author
,
title:
'New: Incident'
)
}
context
'when alerts service is active'
do
before
do
allow
(
project
).
to
receive
(
:alerts_service_activated?
).
and_return
(
true
)
end
it
'updates issue title with the IID'
do
issue
.
save
context
'when the author is Alert Bot'
do
it
'updates issue title with the IID'
do
issue
.
save
expect
(
issue
.
reload
.
title
).
to
eq
(
"New: Incident
#{
issue
.
id
}
"
)
expect
(
issue
.
reload
.
title
).
to
eq
(
"New: Incident
#{
issue
.
id
}
"
)
end
end
context
'when the author is not an Alert Bot'
do
let
(
:author
)
{
create
(
:user
)
}
it
'does not change issue title'
do
expect
{
issue
.
save
}.
not_to
change
{
issue
.
title
}
end
end
end
...
...
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