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
b2e96637
Commit
b2e96637
authored
Jul 15, 2020
by
Ryan Cobb
Committed by
Michael Kozono
Jul 15, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update metrics dashboard base path
parent
d6169420
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
38 additions
and
3 deletions
+38
-3
app/helpers/environments_helper.rb
app/helpers/environments_helper.rb
+14
-3
spec/helpers/environments_helper_spec.rb
spec/helpers/environments_helper_spec.rb
+24
-0
No files found.
app/helpers/environments_helper.rb
View file @
b2e96637
...
...
@@ -24,7 +24,7 @@ module EnvironmentsHelper
def
metrics_data
(
project
,
environment
)
metrics_data
=
{}
metrics_data
.
merge!
(
project_metrics_data
(
project
))
if
project
metrics_data
.
merge!
(
environment_metrics_data
(
environment
))
if
environment
metrics_data
.
merge!
(
environment_metrics_data
(
environment
,
project
))
if
environment
metrics_data
.
merge!
(
project_and_environment_metrics_data
(
project
,
environment
))
if
project
&&
environment
metrics_data
.
merge!
(
static_metrics_data
)
...
...
@@ -66,11 +66,11 @@ module EnvironmentsHelper
}
end
def
environment_metrics_data
(
environment
)
def
environment_metrics_data
(
environment
,
project
=
nil
)
return
{}
unless
environment
{
'metrics-dashboard-base-path'
=>
environment_metrics_path
(
environmen
t
),
'metrics-dashboard-base-path'
=>
metrics_dashboard_base_path
(
environment
,
projec
t
),
'current-environment-name'
=>
environment
.
name
,
'has-metrics'
=>
"
#{
environment
.
has_metrics?
}
"
,
'prometheus-status'
=>
"
#{
environment
.
prometheus_status
}
"
,
...
...
@@ -78,6 +78,17 @@ module EnvironmentsHelper
}
end
def
metrics_dashboard_base_path
(
environment
,
project
)
# This is needed to support our transition from environment scoped metric paths to project scoped.
if
project
path
=
project_metrics_dashboard_path
(
project
)
return
path
if
request
.
path
.
include?
(
path
)
end
environment_metrics_path
(
environment
)
end
def
project_and_environment_metrics_data
(
project
,
environment
)
return
{}
unless
project
&&
environment
...
...
spec/helpers/environments_helper_spec.rb
View file @
b2e96637
...
...
@@ -95,6 +95,30 @@ RSpec.describe EnvironmentsHelper do
it
{
is_expected
.
to
include
(
'environment-state'
=>
'stopped'
)
}
end
context
'when request is from project scoped metrics path'
do
let
(
:request
)
{
double
(
'request'
,
path:
path
)
}
before
do
allow
(
helper
).
to
receive
(
:request
).
and_return
(
request
)
end
context
'/:namespace/:project/-/metrics'
do
let
(
:path
)
{
project_metrics_dashboard_path
(
project
)
}
it
'uses correct path for metrics-dashboard-base-path'
do
expect
(
metrics_data
[
'metrics-dashboard-base-path'
]).
to
eq
(
project_metrics_dashboard_path
(
project
))
end
end
context
'/:namespace/:project/-/metrics/some_custom_dashboard.yml'
do
let
(
:path
)
{
"
#{
project_metrics_dashboard_path
(
project
)
}
/some_custom_dashboard.yml"
}
it
'uses correct path for metrics-dashboard-base-path'
do
expect
(
metrics_data
[
'metrics-dashboard-base-path'
]).
to
eq
(
project_metrics_dashboard_path
(
project
))
end
end
end
end
describe
'#custom_metrics_available?'
do
...
...
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