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
3f35eade
Commit
3f35eade
authored
Apr 10, 2020
by
Sean Arnold
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Tighten up specs and extract method
parent
5df1be54
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
7 deletions
+17
-7
lib/gitlab/alerting/alert.rb
lib/gitlab/alerting/alert.rb
+9
-5
spec/lib/gitlab/alerting/alert_spec.rb
spec/lib/gitlab/alerting/alert_spec.rb
+8
-2
No files found.
lib/gitlab/alerting/alert.rb
View file @
3f35eade
...
...
@@ -120,15 +120,19 @@ module Gitlab
end
def
parse_gitlab_alert_from_payload
alerts_found
=
matching_gitlab_alerts
return
if
alerts_found
.
blank?
||
alerts_found
.
size
>
1
alerts_found
.
first
end
def
matching_gitlab_alerts
return
unless
metric_id
||
gitlab_prometheus_alert_id
alerts_found
=
Projects
::
Prometheus
::
AlertsFinder
Projects
::
Prometheus
::
AlertsFinder
.
new
(
project:
project
,
metric:
metric_id
,
id:
gitlab_prometheus_alert_id
)
.
execute
return
if
alerts_found
.
empty?
||
alerts_found
.
size
>
1
alerts_found
.
first
end
def
parse_title_from_payload
...
...
spec/lib/gitlab/alerting/alert_spec.rb
View file @
3f35eade
...
...
@@ -13,7 +13,10 @@ describe Gitlab::Alerting::Alert do
let
(
:gitlab_alert_id
)
{
gitlab_alert
.
id
}
before
do
payload
[
'labels'
]
=
{
'gitlab_prometheus_alert_id'
=>
gitlab_alert_id
}
payload
[
'labels'
]
=
{
'gitlab_alert_id'
=>
gitlab_alert
.
prometheus_metric_id
.
to_s
,
'gitlab_prometheus_alert_id'
=>
gitlab_alert_id
}
end
end
...
...
@@ -81,7 +84,10 @@ describe Gitlab::Alerting::Alert do
context
'alert id given in params'
do
before
do
payload
[
'labels'
]
=
{
'gitlab_prometheus_alert_id'
=>
second_gitlab_alert
.
id
}
payload
[
'labels'
]
=
{
'gitlab_alert_id'
=>
gitlab_alert
.
prometheus_metric_id
.
to_s
,
'gitlab_prometheus_alert_id'
=>
second_gitlab_alert
.
id
}
end
it
{
is_expected
.
to
eq
(
second_gitlab_alert
)
}
...
...
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