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
28e612cb
Commit
28e612cb
authored
Aug 12, 2020
by
Ryan Cobb
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Consolidate controller and request specs
parent
fbb215b6
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
16 additions
and
69 deletions
+16
-69
spec/controllers/projects/metrics_dashboard_controller_spec.rb
...controllers/projects/metrics_dashboard_controller_spec.rb
+0
-69
spec/requests/projects/metrics_dashboard_spec.rb
spec/requests/projects/metrics_dashboard_spec.rb
+16
-0
No files found.
spec/controllers/projects/metrics_dashboard_controller_spec.rb
deleted
100644 → 0
View file @
fbb215b6
# frozen_string_literal: true
require
'spec_helper'
RSpec
.
describe
Projects
::
MetricsDashboardController
do
let_it_be
(
:project
)
{
create
(
:project
)
}
let_it_be
(
:maintainer
)
{
create
(
:user
,
name:
'main-dos'
).
tap
{
|
u
|
project
.
add_maintainer
(
u
)
}
}
let_it_be
(
:reporter
)
{
create
(
:user
,
name:
'repo-dos'
).
tap
{
|
u
|
project
.
add_reporter
(
u
)
}
}
let!
(
:default_environment
)
{
create
(
:environment
,
name:
'default'
,
project:
project
)
}
let!
(
:environment_2
)
{
create
(
:environment
,
name:
'staging'
,
project:
project
)
}
let
(
:user
)
{
maintainer
}
before
do
sign_in
(
user
)
end
describe
'GET #show'
do
context
'without environment'
do
it
'uses default environment'
do
get
:show
,
params:
metrics_dashboard_params
(
dashboard_path:
'some/path.yml'
)
expect
(
assigns
(
:environment
)).
to
eq
(
default_environment
)
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
end
end
context
'with environment specified'
do
it
'assigns specified environment'
do
get
:show
,
params:
metrics_dashboard_params
(
dashboard_path:
'some/path.yml'
,
environment:
environment_2
.
id
)
expect
(
assigns
(
:environment
)).
to
eq
(
environment_2
)
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
end
end
context
'permissions'
do
before
do
allow
(
controller
).
to
receive
(
:can?
).
and_return
true
end
it
'checks :metrics_dashboard_ability'
do
expect
(
controller
).
to
receive
(
:can?
).
with
(
anything
,
:metrics_dashboard
,
anything
)
get
:show
,
params:
metrics_dashboard_params
end
end
context
'with anonymous user and public dashboard visibility'
do
let
(
:user
)
{
create
(
:user
)
}
let
(
:project
)
do
create
(
:project
,
:public
,
metrics_dashboard_access_level:
'enabled'
)
end
it
'returns success'
do
get
:show
,
params:
metrics_dashboard_params
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
end
end
end
def
metrics_dashboard_params
(
opts
=
{})
opts
.
reverse_merge
({
namespace_id:
project
.
namespace
,
project_id:
project
})
end
end
spec/requests/projects/metrics_dashboard_spec.rb
View file @
28e612cb
...
...
@@ -23,6 +23,22 @@ RSpec.describe 'metrics dashboard page' do
send_request
expect
(
assigns
(
:environment
).
id
).
to
eq
(
environment
.
id
)
end
context
'with anonymous user and public dashboard visibility'
do
let
(
:anonymous_user
)
{
create
(
:user
)
}
let
(
:project
)
do
create
(
:project
,
:public
,
metrics_dashboard_access_level:
'enabled'
)
end
before
do
login_as
(
anonymous_user
)
end
it
'returns 200'
do
send_request
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
end
end
end
describe
'GET /:namespace/:project/-/metrics?environment=:environment.id'
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