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
6192c61f
Commit
6192c61f
authored
May 27, 2020
by
Adam Hegyi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Eliminate code duplication in group VSA controller
parent
8eff84b9
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
43 additions
and
25 deletions
+43
-25
ee/app/controllers/groups/analytics/cycle_analytics_controller.rb
...ontrollers/groups/analytics/cycle_analytics_controller.rb
+2
-25
ee/spec/controllers/groups/analytics/cycle_analytics_controller_spec.rb
...llers/groups/analytics/cycle_analytics_controller_spec.rb
+41
-0
No files found.
ee/app/controllers/groups/analytics/cycle_analytics_controller.rb
View file @
6192c61f
# frozen_string_literal: true
class
Groups::Analytics::CycleAnalyticsController
<
Groups
::
Analytics
::
ApplicationController
include
CycleAnalyticsParams
class
Groups::Analytics::CycleAnalyticsController
<
Analytics
::
CycleAnalyticsController
layout
'group'
check_feature_flag
Gitlab
::
Analytics
::
CYCLE_ANALYTICS_FEATURE_FLAG
increment_usage_counter
Gitlab
::
UsageDataCounters
::
CycleAnalyticsCounter
,
:views
,
only: :show
before_action
do
push_frontend_feature_flag
(
:cycle_analytics_scatterplot_enabled
,
default_enabled:
true
)
push_frontend_feature_flag
(
:cycle_analytics_scatterplot_median_enabled
,
default_enabled:
true
)
push_frontend_feature_flag
(
:value_stream_analytics_path_navigation
,
@group
)
end
before_action
:load_group
,
only: :show
before_action
:load_project
,
only: :show
before_action
:build_request_params
,
only: :show
def
build_request_params
@request_params
||=
Gitlab
::
Analytics
::
CycleAnalytics
::
RequestParams
.
new
(
allowed_params
.
merge
(
group:
@group
),
current_user:
current_user
)
end
def
allowed_params
params
.
permit
(
:created_after
,
:created_before
,
project_ids:
[]
)
render_403
unless
can?
(
current_user
,
:read_group_cycle_analytics
,
@group
)
end
end
ee/spec/controllers/groups/analytics/cycle_analytics_controller_spec.rb
0 → 100644
View file @
6192c61f
# frozen_string_literal: true
require
'spec_helper'
describe
Groups
::
Analytics
::
CycleAnalyticsController
do
let
(
:group
)
{
create
(
:group
)
}
let
(
:user
)
{
create
(
:user
)
}
before
do
group
.
add_maintainer
(
user
)
sign_in
(
user
)
end
context
'when the license is available'
do
before
do
stub_licensed_features
(
cycle_analytics_for_groups:
true
)
end
it
'succeeds'
do
get
(
:show
,
params:
{
group_id:
group
})
expect
(
response
).
to
be_successful
end
end
context
'when the license is missing'
do
it
'renders 403 error'
do
get
(
:show
,
params:
{
group_id:
group
})
expect
(
response
).
to
have_gitlab_http_status
(
:forbidden
)
end
end
context
'when non-existent group is given'
do
it
'renders 403 error'
do
get
(
:show
,
params:
{
group_id:
'unknown'
})
expect
(
response
).
to
have_gitlab_http_status
(
:not_found
)
end
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