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
4db8cec3
Commit
4db8cec3
authored
Oct 18, 2019
by
Jason Goodman
Committed by
Mayra Cabrera
Oct 18, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add feature flag for environments dashboard backend
Return 404 if disabled
parent
bf9732ce
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
89 additions
and
8 deletions
+89
-8
ee/app/controllers/operations_controller.rb
ee/app/controllers/operations_controller.rb
+5
-6
ee/app/helpers/ee/dashboard_helper.rb
ee/app/helpers/ee/dashboard_helper.rb
+1
-1
ee/spec/controllers/operations_controller_spec.rb
ee/spec/controllers/operations_controller_spec.rb
+83
-1
No files found.
ee/app/controllers/operations_controller.rb
View file @
4db8cec3
...
...
@@ -2,8 +2,7 @@
class
OperationsController
<
ApplicationController
before_action
:authorize_read_operations_dashboard!
before_action
:dashboard_feature_flag
,
only:
[
:environments
]
before_action
:environments_dashboard_feature_flag
,
only:
%i[environments environments_list]
respond_to
:json
,
only:
[
:list
]
...
...
@@ -15,10 +14,6 @@ class OperationsController < ApplicationController
def
environments
end
def
dashboard_feature_flag
push_frontend_feature_flag
(
:environments_dashboard
)
end
def
list
Gitlab
::
PollingInterval
.
set_header
(
response
,
interval:
POLLING_INTERVAL
)
projects
=
load_projects
(
current_user
)
...
...
@@ -61,6 +56,10 @@ class OperationsController < ApplicationController
render_404
unless
can?
(
current_user
,
:read_operations_dashboard
)
end
def
environments_dashboard_feature_flag
render_404
unless
Feature
.
enabled?
(
:environments_dashboard
,
current_user
)
end
def
load_projects
(
current_user
)
Dashboard
::
Operations
::
ListService
.
new
(
current_user
).
execute
end
...
...
ee/app/helpers/ee/dashboard_helper.rb
View file @
4db8cec3
...
...
@@ -39,7 +39,7 @@ module EE
links
<<
:analytics
if
::
Gitlab
::
Analytics
.
any_features_enabled?
if
can?
(
current_user
,
:read_operations_dashboard
)
links
<<
:environments
if
::
Feature
.
enabled?
(
:environments_dashboard
)
links
<<
:environments
if
::
Feature
.
enabled?
(
:environments_dashboard
,
current_user
)
links
<<
:operations
end
...
...
ee/spec/controllers/operations_controller_spec.rb
View file @
4db8cec3
...
...
@@ -34,6 +34,15 @@ describe OperationsController do
expect
(
response
).
to
render_template
(
:index
)
end
it
'renders regardless of the environments_dashboard feature flag'
do
stub_feature_flags
(
environments_dashboard:
{
enabled:
false
,
thing:
user
})
get
:index
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
response
).
to
render_template
(
:index
)
end
context
'with an anonymous user'
do
before
do
sign_out
(
user
)
...
...
@@ -57,6 +66,24 @@ describe OperationsController do
expect
(
response
).
to
render_template
(
:environments
)
end
it
'returns a 404 when the feature is disabled'
do
stub_feature_flags
(
environments_dashboard:
{
enabled:
false
,
thing:
user
})
get
:environments
expect
(
response
).
to
have_gitlab_http_status
(
:not_found
)
end
it
'renders the view when the feature is disabled for a different user'
do
other_user
=
create
(
:user
)
stub_feature_flags
(
environments_dashboard:
{
enabled:
false
,
thing:
other_user
})
get
:environments
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
response
).
to
render_template
(
:environments
)
end
context
'with an anonymous user'
do
before
do
sign_out
(
user
)
...
...
@@ -138,6 +165,17 @@ describe OperationsController do
expect
(
expected_project
[
'last_alert'
][
'id'
]).
to
eq
(
last_firing_alert
.
id
)
end
it
'returns a list of added projects regardless of the environments_dashboard feature flag'
do
stub_feature_flags
(
environments_dashboard:
{
enabled:
false
,
thing:
user
})
get
:list
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
response
).
to
match_response_schema
(
'dashboard/operations/list'
,
dir:
'ee'
)
expect
(
json_response
[
'projects'
].
size
).
to
eq
(
1
)
expect
(
expected_project
[
'id'
]).
to
eq
(
project
.
id
)
end
context
'without sufficient access level'
do
before
do
project
.
add_reporter
(
user
)
...
...
@@ -226,6 +264,30 @@ describe OperationsController do
user
.
update!
(
ops_dashboard_projects:
[
project
])
end
it
'returns a 404 when the feature is disabled'
do
stub_feature_flags
(
environments_dashboard:
{
enabled:
false
,
thing:
user
})
environment
=
create
(
:environment
,
project:
project
)
ci_build
=
create
(
:ci_build
,
project:
project
)
create
(
:deployment
,
:success
,
project:
project
,
environment:
environment
,
deployable:
ci_build
)
get
:environments_list
expect
(
response
).
to
have_gitlab_http_status
(
:not_found
)
end
it
'returns a project when the feature is disabled for another user'
do
other_user
=
create
(
:user
)
stub_feature_flags
(
environments_dashboard:
{
enabled:
false
,
thing:
other_user
})
environment
=
create
(
:environment
,
project:
project
)
ci_build
=
create
(
:ci_build
,
project:
project
)
create
(
:deployment
,
:success
,
project:
project
,
environment:
environment
,
deployable:
ci_build
)
get
:environments_list
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
response
).
to
match_response_schema
(
'dashboard/operations/environments_list'
,
dir:
'ee'
)
end
it
'returns a project without an environment'
do
get
:environments_list
...
...
@@ -452,6 +514,16 @@ describe OperationsController do
expect
(
user
.
ops_dashboard_projects
).
to
contain_exactly
(
project_a
,
project_b
)
end
it
'adds projects to the dashboard regardless of the environments_dashboard feature flag'
do
stub_feature_flags
(
environments_dashboard:
{
enabled:
false
,
thing:
user
})
post
:create
,
params:
{
project_ids:
[
project_a
.
id
,
project_b
.
id
.
to_s
]
}
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
json_response
).
to
match_schema
(
'dashboard/operations/add'
,
dir:
'ee'
)
expect
(
json_response
[
'added'
]).
to
contain_exactly
(
project_a
.
id
,
project_b
.
id
)
end
it
'cannot add a project twice'
do
post
:create
,
params:
{
project_ids:
[
project_a
.
id
,
project_a
.
id
]
}
...
...
@@ -530,7 +602,17 @@ describe OperationsController do
expect
(
response
).
to
have_gitlab_http_status
(
200
)
user
.
reload
expect
(
user
.
ops_dashboard_projects
).
not_to
eq
([
project
])
expect
(
user
.
ops_dashboard_projects
).
to
eq
([])
end
it
'removes a project regardless of the environments_dashboard feature flag'
do
stub_feature_flags
(
environments_dashboard:
{
enabled:
false
,
thing:
user
})
delete
:destroy
,
params:
{
project_id:
project
.
id
}
expect
(
response
).
to
have_gitlab_http_status
(
200
)
user
.
reload
expect
(
user
.
ops_dashboard_projects
).
to
eq
([])
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