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
0
Merge Requests
0
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
Boxiang Sun
gitlab-ce
Commits
ec399e65
Commit
ec399e65
authored
May 20, 2019
by
Sarah Yasonik
Committed by
Jan Provaznik
May 20, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Require time window params in metrics dashboard
parent
47f5d0cf
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
10 additions
and
13 deletions
+10
-13
app/controllers/projects/environments_controller.rb
app/controllers/projects/environments_controller.rb
+0
-1
spec/controllers/projects/environments_controller_spec.rb
spec/controllers/projects/environments_controller_spec.rb
+10
-12
No files found.
app/controllers/projects/environments_controller.rb
View file @
ec399e65
...
@@ -221,7 +221,6 @@ class Projects::EnvironmentsController < Projects::ApplicationController
...
@@ -221,7 +221,6 @@ class Projects::EnvironmentsController < Projects::ApplicationController
def
metrics_params
def
metrics_params
return
unless
Feature
.
enabled?
(
:metrics_time_window
,
project
)
return
unless
Feature
.
enabled?
(
:metrics_time_window
,
project
)
return
unless
params
[
:start
].
present?
||
params
[
:end
].
present?
params
.
require
([
:start
,
:end
])
params
.
require
([
:start
,
:end
])
end
end
...
...
spec/controllers/projects/environments_controller_spec.rb
View file @
ec399e65
...
@@ -383,6 +383,8 @@ describe Projects::EnvironmentsController do
...
@@ -383,6 +383,8 @@ describe Projects::EnvironmentsController do
end
end
describe
'GET #additional_metrics'
do
describe
'GET #additional_metrics'
do
let
(
:window_params
)
{
{
start:
'1554702993.5398998'
,
end:
'1554717396.996232'
}
}
before
do
before
do
allow
(
controller
).
to
receive
(
:environment
).
and_return
(
environment
)
allow
(
controller
).
to
receive
(
:environment
).
and_return
(
environment
)
end
end
...
@@ -394,7 +396,7 @@ describe Projects::EnvironmentsController do
...
@@ -394,7 +396,7 @@ describe Projects::EnvironmentsController do
context
'when requesting metrics as JSON'
do
context
'when requesting metrics as JSON'
do
it
'returns a metrics JSON document'
do
it
'returns a metrics JSON document'
do
additional_metrics
additional_metrics
(
window_params
)
expect
(
response
).
to
have_gitlab_http_status
(
204
)
expect
(
response
).
to
have_gitlab_http_status
(
204
)
expect
(
json_response
).
to
eq
({})
expect
(
json_response
).
to
eq
({})
...
@@ -414,23 +416,19 @@ describe Projects::EnvironmentsController do
...
@@ -414,23 +416,19 @@ describe Projects::EnvironmentsController do
end
end
it
'returns a metrics JSON document'
do
it
'returns a metrics JSON document'
do
additional_metrics
additional_metrics
(
window_params
)
expect
(
response
).
to
be_ok
expect
(
response
).
to
be_ok
expect
(
json_response
[
'success'
]).
to
be
(
true
)
expect
(
json_response
[
'success'
]).
to
be
(
true
)
expect
(
json_response
[
'data'
]).
to
eq
({})
expect
(
json_response
[
'data'
]).
to
eq
({})
expect
(
json_response
[
'last_update'
]).
to
eq
(
42
)
expect
(
json_response
[
'last_update'
]).
to
eq
(
42
)
end
end
end
context
'when time params are provided'
do
context
'when time params are missing'
do
it
'returns a metrics JSON document'
do
it
'raises an error when window params are missing'
do
additional_metrics
(
start:
'1554702993.5398998'
,
end:
'1554717396.996232'
)
expect
{
additional_metrics
}
.
to
raise_error
(
ActionController
::
ParameterMissing
)
expect
(
response
).
to
be_ok
expect
(
json_response
[
'success'
]).
to
be
(
true
)
expect
(
json_response
[
'data'
]).
to
eq
({})
expect
(
json_response
[
'last_update'
]).
to
eq
(
42
)
end
end
end
end
end
...
@@ -450,7 +448,7 @@ describe Projects::EnvironmentsController do
...
@@ -450,7 +448,7 @@ describe Projects::EnvironmentsController do
end
end
it
'raises an error when start is missing'
do
it
'raises an error when start is missing'
do
expect
{
additional_metrics
(
start
:
'1552647300.651094'
)
}
expect
{
additional_metrics
(
end
:
'1552647300.651094'
)
}
.
to
raise_error
(
ActionController
::
ParameterMissing
)
.
to
raise_error
(
ActionController
::
ParameterMissing
)
end
end
...
...
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