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
b178dceb
Commit
b178dceb
authored
Feb 11, 2020
by
syasonik
Committed by
Jan Provaznik
Feb 14, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Swap metrics_dashboard to use metric_id and env_id
parent
1a623a92
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
4 deletions
+18
-4
ee/app/controllers/projects/prometheus/alerts_controller.rb
ee/app/controllers/projects/prometheus/alerts_controller.rb
+2
-2
ee/spec/controllers/projects/prometheus/alerts_controller_spec.rb
...controllers/projects/prometheus/alerts_controller_spec.rb
+16
-2
No files found.
ee/app/controllers/projects/prometheus/alerts_controller.rb
View file @
b178dceb
...
...
@@ -14,7 +14,7 @@ module Projects
prepend_before_action
:repository
,
:project_without_auth
,
only:
[
:notify
]
before_action
:authorize_read_prometheus_alerts!
,
except:
[
:notify
]
before_action
:alert
,
only:
[
:update
,
:show
,
:destroy
]
before_action
:alert
,
only:
[
:update
,
:show
,
:destroy
,
:metrics_dashboard
]
def
index
render
json:
serialize_as_json
(
alerts
)
...
...
@@ -140,7 +140,7 @@ module Projects
def
metrics_dashboard_params
{
embedded:
true
,
prometheus_alert_id:
params
[
:id
].
to_i
prometheus_alert_id:
alert
.
id
}
end
end
...
...
ee/spec/controllers/projects/prometheus/alerts_controller_spec.rb
View file @
b178dceb
...
...
@@ -364,19 +364,33 @@ describe Projects::Prometheus::AlertsController do
end
it
'returns a json object with the correct keys'
do
get
:metrics_dashboard
,
params:
request_params
(
id:
aler
t
.
id
),
format: :json
get
:metrics_dashboard
,
params:
request_params
(
id:
metric
.
id
,
environment_id:
alert
.
environmen
t
.
id
),
format: :json
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
json_response
.
keys
).
to
contain_exactly
(
'dashboard'
,
'status'
)
end
it
'is the correct embed'
do
get
:metrics_dashboard
,
params:
request_params
(
id:
aler
t
.
id
),
format: :json
get
:metrics_dashboard
,
params:
request_params
(
id:
metric
.
id
,
environment_id:
alert
.
environmen
t
.
id
),
format: :json
title
=
json_response
[
'dashboard'
][
'panel_groups'
][
0
][
'panels'
][
0
][
'title'
]
expect
(
title
).
to
eq
(
metric
.
title
)
end
it
'finds the first alert embed without environment_id'
do
get
:metrics_dashboard
,
params:
request_params
(
id:
metric
.
id
),
format: :json
title
=
json_response
[
'dashboard'
][
'panel_groups'
][
0
][
'panels'
][
0
][
'title'
]
expect
(
title
).
to
eq
(
metric
.
title
)
end
it
'returns 404 for non-existant alerts'
do
get
:metrics_dashboard
,
params:
request_params
(
id:
0
),
format: :json
expect
(
response
).
to
have_gitlab_http_status
(
:not_found
)
end
end
def
project_params
(
opts
=
{})
...
...
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