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
3c21e545
Commit
3c21e545
authored
May 08, 2020
by
syasonik
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use new integer value for status
parent
6bb5e629
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
18 additions
and
6 deletions
+18
-6
app/services/alert_management/update_alert_status_service.rb
app/services/alert_management/update_alert_status_service.rb
+16
-4
spec/graphql/mutations/alert_management/update_alert_status_spec.rb
...ql/mutations/alert_management/update_alert_status_spec.rb
+1
-1
spec/services/alert_management/update_alert_status_service_spec.rb
...ices/alert_management/update_alert_status_service_spec.rb
+1
-1
No files found.
app/services/alert_management/update_alert_status_service.rb
View file @
3c21e545
...
@@ -2,17 +2,19 @@
...
@@ -2,17 +2,19 @@
module
AlertManagement
module
AlertManagement
class
UpdateAlertStatusService
class
UpdateAlertStatusService
include
Gitlab
::
Utils
::
StrongMemoize
# @param alert [AlertManagement::Alert]
# @param status [Integer] Must match a value from AlertManagement::Alert::STATUSES
def
initialize
(
alert
,
status
)
def
initialize
(
alert
,
status
)
@alert
=
alert
@alert
=
alert
@status
=
status
@status
=
status
end
end
def
execute
def
execute
return
error
(
'Invalid status'
)
unless
AlertManagement
::
Alert
::
STATUSES
.
key?
(
status
.
to_sym
)
return
error
(
'Invalid status'
)
unless
status_key
alert
.
status_event
=
AlertManagement
::
Alert
::
STATUS_EVENTS
[
status
.
to_sym
]
if
alert
.
save
if
alert
.
update
(
status_event:
status_event
)
success
success
else
else
error
(
alert
.
errors
.
full_messages
.
to_sentence
)
error
(
alert
.
errors
.
full_messages
.
to_sentence
)
...
@@ -23,6 +25,16 @@ module AlertManagement
...
@@ -23,6 +25,16 @@ module AlertManagement
attr_reader
:alert
,
:status
attr_reader
:alert
,
:status
def
status_key
strong_memoize
(
:status_key
)
do
AlertManagement
::
Alert
::
STATUSES
.
key
(
status
)
end
end
def
status_event
AlertManagement
::
Alert
::
STATUS_EVENTS
[
status_key
]
end
def
success
def
success
ServiceResponse
.
success
(
payload:
{
alert:
alert
})
ServiceResponse
.
success
(
payload:
{
alert:
alert
})
end
end
...
...
spec/graphql/mutations/alert_management/update_alert_status_spec.rb
View file @
3c21e545
...
@@ -6,7 +6,7 @@ describe Mutations::AlertManagement::UpdateAlertStatus do
...
@@ -6,7 +6,7 @@ describe Mutations::AlertManagement::UpdateAlertStatus do
let_it_be
(
:current_user
)
{
create
(
:user
)
}
let_it_be
(
:current_user
)
{
create
(
:user
)
}
let_it_be
(
:alert
)
{
create
(
:alert_management_alert
,
status:
'triggered'
)
}
let_it_be
(
:alert
)
{
create
(
:alert_management_alert
,
status:
'triggered'
)
}
let_it_be
(
:project
)
{
alert
.
project
}
let_it_be
(
:project
)
{
alert
.
project
}
let
(
:new_status
)
{
'acknowledged'
}
let
(
:new_status
)
{
Types
::
AlertManagement
::
StatusEnum
.
values
[
'ACKNOWLEDGED'
].
value
}
let
(
:args
)
{
{
status:
new_status
,
project_path:
project
.
full_path
,
iid:
alert
.
iid
}
}
let
(
:args
)
{
{
status:
new_status
,
project_path:
project
.
full_path
,
iid:
alert
.
iid
}
}
specify
{
expect
(
described_class
).
to
require_graphql_authorizations
(
:update_alert_management_alert
)
}
specify
{
expect
(
described_class
).
to
require_graphql_authorizations
(
:update_alert_management_alert
)
}
...
...
spec/services/alert_management/update_alert_status_service_spec.rb
View file @
3c21e545
...
@@ -8,7 +8,7 @@ describe AlertManagement::UpdateAlertStatusService do
...
@@ -8,7 +8,7 @@ describe AlertManagement::UpdateAlertStatusService do
describe
'#execute'
do
describe
'#execute'
do
subject
(
:execute
)
{
described_class
.
new
(
alert
,
new_status
).
execute
}
subject
(
:execute
)
{
described_class
.
new
(
alert
,
new_status
).
execute
}
let
(
:new_status
)
{
'acknowledged'
}
let
(
:new_status
)
{
Types
::
AlertManagement
::
StatusEnum
.
values
[
'ACKNOWLEDGED'
].
value
}
it
'updates the status'
do
it
'updates the status'
do
expect
{
execute
}.
to
change
{
alert
.
acknowledged?
}.
to
(
true
)
expect
{
execute
}.
to
change
{
alert
.
acknowledged?
}.
to
(
true
)
...
...
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