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
1647339d
Commit
1647339d
authored
Jul 06, 2020
by
Sean Arnold
Committed by
Markus Koller
Jul 06, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Resolve "Automatically mark To-do as done when an alert is resolved"
parent
3e2e2a8b
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
29 additions
and
2 deletions
+29
-2
app/services/alert_management/update_alert_status_service.rb
app/services/alert_management/update_alert_status_service.rb
+6
-1
changelogs/unreleased/216143-resolve-todo-for-user-after-alert-resolve.yml
...ased/216143-resolve-todo-for-user-after-alert-resolve.yml
+5
-0
spec/services/alert_management/update_alert_status_service_spec.rb
...ices/alert_management/update_alert_status_service_spec.rb
+18
-1
No files found.
app/services/alert_management/update_alert_status_service.rb
View file @
1647339d
...
...
@@ -18,6 +18,7 @@ module AlertManagement
return
error_invalid_status
unless
status_key
if
alert
.
update
(
status_event:
status_event
)
resolve_todos
if
resolved?
success
else
error
(
alert
.
errors
.
full_messages
.
to_sentence
)
...
...
@@ -28,12 +29,16 @@ module AlertManagement
attr_reader
:alert
,
:user
,
:status
delegate
:project
,
to: :alert
delegate
:project
,
:resolved?
,
to: :alert
def
allowed?
user
.
can?
(
:update_alert_management_alert
,
project
)
end
def
resolve_todos
TodoService
.
new
.
resolve_todos_for_target
(
alert
,
user
)
end
def
status_key
strong_memoize
(
:status_key
)
do
AlertManagement
::
Alert
::
STATUSES
.
key
(
status
)
...
...
changelogs/unreleased/216143-resolve-todo-for-user-after-alert-resolve.yml
0 → 100644
View file @
1647339d
---
title
:
Resolve user's todo when an alert is resolved
merge_request
:
35700
author
:
type
:
added
spec/services/alert_management/update_alert_status_service_spec.rb
View file @
1647339d
...
...
@@ -25,7 +25,7 @@ RSpec.describe AlertManagement::UpdateAlertStatusService do
end
end
let
(
:new_status
)
{
Types
::
AlertManagement
::
StatusEnum
.
values
[
'ACKNOWLEDGED'
].
value
}
let
(
:new_status
)
{
AlertManagement
::
Alert
::
STATUSES
[
:acknowledged
]
}
let
(
:can_update
)
{
true
}
subject
(
:response
)
{
service
.
execute
}
...
...
@@ -45,6 +45,23 @@ RSpec.describe AlertManagement::UpdateAlertStatusService do
expect
{
response
}.
to
change
{
alert
.
acknowledged?
}.
to
(
true
)
end
context
'resolving status'
do
let
(
:new_status
)
{
AlertManagement
::
Alert
::
STATUSES
[
:resolved
]
}
it
'updates the status'
do
expect
{
response
}.
to
change
{
alert
.
resolved?
}.
to
(
true
)
end
context
'user has a pending todo'
do
let
(
:user
)
{
create
(
:user
)
}
let!
(
:todo
)
{
create
(
:todo
,
:pending
,
target:
alert
,
user:
user
,
project:
alert
.
project
)
}
it
'resolves the todo'
do
expect
{
response
}.
to
change
{
todo
.
reload
.
state
}.
from
(
'pending'
).
to
(
'done'
)
end
end
end
context
'when user has no permissions'
do
let
(
:can_update
)
{
false
}
...
...
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