Commit 41a2e1c5 authored by Adam Hegyi's avatar Adam Hegyi

Remove analytics navbar feature flags

- analytics_pages_under_project_analytics_sidebar
- analytics_pages_under_group_analytics_sidebar
- group_level_productivity_analytics
parent 0a06be7d
...@@ -31,7 +31,6 @@ module AnalyticsNavbarHelper ...@@ -31,7 +31,6 @@ module AnalyticsNavbarHelper
end end
def cycle_analytics_navbar_link(project, current_user) def cycle_analytics_navbar_link(project, current_user)
return unless Feature.enabled?(:analytics_pages_under_project_analytics_sidebar, project, default_enabled: true)
return unless project_nav_tab?(:cycle_analytics) return unless project_nav_tab?(:cycle_analytics)
navbar_sub_item( navbar_sub_item(
...@@ -43,7 +42,6 @@ module AnalyticsNavbarHelper ...@@ -43,7 +42,6 @@ module AnalyticsNavbarHelper
end end
def repository_analytics_navbar_link(project, current_user) def repository_analytics_navbar_link(project, current_user)
return if Feature.disabled?(:analytics_pages_under_project_analytics_sidebar, project, default_enabled: true)
return if project.empty_repo? return if project.empty_repo?
navbar_sub_item( navbar_sub_item(
...@@ -55,7 +53,6 @@ module AnalyticsNavbarHelper ...@@ -55,7 +53,6 @@ module AnalyticsNavbarHelper
end end
def ci_cd_analytics_navbar_link(project, current_user) def ci_cd_analytics_navbar_link(project, current_user)
return unless Feature.enabled?(:analytics_pages_under_project_analytics_sidebar, project, default_enabled: true)
return unless project_nav_tab?(:pipelines) return unless project_nav_tab?(:pipelines)
return unless project.feature_available?(:builds, current_user) || !project.empty_repo? return unless project.feature_available?(:builds, current_user) || !project.empty_repo?
......
- should_display_analytics_pages_in_sidebar = Feature.enabled?(:analytics_pages_under_group_analytics_sidebar, @group, default_enabled: true)
- issues_count = group_issues_count(state: 'opened') - issues_count = group_issues_count(state: 'opened')
- merge_requests_count = group_merge_requests_count(state: 'opened') - merge_requests_count = group_merge_requests_count(state: 'opened')
...@@ -13,8 +12,7 @@ ...@@ -13,8 +12,7 @@
%ul.sidebar-top-level-items.qa-group-sidebar %ul.sidebar-top-level-items.qa-group-sidebar
- if group_sidebar_link?(:overview) - if group_sidebar_link?(:overview)
- paths = group_overview_nav_link_paths - paths = group_overview_nav_link_paths
- paths << 'contribution_analytics#show' unless should_display_analytics_pages_in_sidebar = nav_link(path: paths, unless: -> { current_path?('groups/contribution_analytics#show') }, html_options: { class: 'home' }) do
= nav_link(path: paths, unless: -> { should_display_analytics_pages_in_sidebar && current_path?('groups/contribution_analytics#show') }, html_options: { class: 'home' }) do
= link_to group_path(@group) do = link_to group_path(@group) do
.nav-icon-container .nav-icon-container
= sprite_icon('home') = sprite_icon('home')
...@@ -45,19 +43,10 @@ ...@@ -45,19 +43,10 @@
%span %span
= _('Activity') = _('Activity')
- unless should_display_analytics_pages_in_sidebar
- if group_sidebar_link?(:contribution_analytics)
= nav_link(path: 'contribution_analytics#show') do
= link_to group_contribution_analytics_path(@group), title: _('Contribution'), data: { placement: 'right', qa_selector: 'contribution_analytics_link' } do
%span
= _('Contribution')
= render_if_exists 'layouts/nav/group_insights_link'
= render_if_exists "layouts/nav/ee/epic_link", group: @group = render_if_exists "layouts/nav/ee/epic_link", group: @group
- if group_sidebar_link?(:issues) - if group_sidebar_link?(:issues)
= nav_link(path: group_issues_sub_menu_items, unless: -> { should_display_analytics_pages_in_sidebar && current_path?('issues_analytics#show') }) do = nav_link(path: group_issues_sub_menu_items, unless: -> { current_path?('issues_analytics#show') }) do
= link_to issues_group_path(@group), data: { qa_selector: 'group_issues_item' } do = link_to issues_group_path(@group), data: { qa_selector: 'group_issues_item' } do
.nav-icon-container .nav-icon-container
= sprite_icon('issues') = sprite_icon('issues')
...@@ -84,9 +73,6 @@ ...@@ -84,9 +73,6 @@
%span %span
= boards_link_text = boards_link_text
- unless should_display_analytics_pages_in_sidebar
= render_if_exists 'layouts/nav/issues_analytics_link'
- if group_sidebar_link?(:labels) - if group_sidebar_link?(:labels)
= nav_link(path: 'labels#index') do = nav_link(path: 'labels#index') do
= link_to group_labels_path(@group), title: _('Labels') do = link_to group_labels_path(@group), title: _('Labels') do
......
- should_display_analytics_pages_in_sidebar = Feature.enabled?(:analytics_pages_under_project_analytics_sidebar, @project, default_enabled: true)
.nav-sidebar{ class: ("sidebar-collapsed-desktop" if collapsed_sidebar?) } .nav-sidebar{ class: ("sidebar-collapsed-desktop" if collapsed_sidebar?) }
.nav-sidebar-inner-scroll .nav-sidebar-inner-scroll
- can_edit = can?(current_user, :admin_project, @project) - can_edit = can?(current_user, :admin_project, @project)
...@@ -10,9 +8,7 @@ ...@@ -10,9 +8,7 @@
.sidebar-context-title .sidebar-context-title
= @project.name = @project.name
%ul.sidebar-top-level-items.qa-project-sidebar %ul.sidebar-top-level-items.qa-project-sidebar
- paths = sidebar_projects_paths = nav_link(path: sidebar_projects_paths, html_options: { class: 'home' }) do
- paths << 'cycle_analytics#show' unless should_display_analytics_pages_in_sidebar
= nav_link(path: paths, html_options: { class: 'home' }) do
= link_to project_path(@project), class: 'shortcuts-project rspec-project-link', data: { qa_selector: 'project_link' } do = link_to project_path(@project), class: 'shortcuts-project rspec-project-link', data: { qa_selector: 'project_link' } do
.nav-icon-container .nav-icon-container
= sprite_icon('home') = sprite_icon('home')
...@@ -39,17 +35,8 @@ ...@@ -39,17 +35,8 @@
%span= _('Releases') %span= _('Releases')
- unless should_display_analytics_pages_in_sidebar
- if can?(current_user, :read_cycle_analytics, @project)
= nav_link(path: 'cycle_analytics#show') do
= link_to project_cycle_analytics_path(@project), title: _('Value Stream'), class: 'shortcuts-project-cycle-analytics' do
%span= _('Value Stream')
= render_if_exists 'layouts/nav/project_insights_link'
- if project_nav_tab? :files - if project_nav_tab? :files
= nav_link(controller: sidebar_repository_paths, unless: -> { should_display_analytics_pages_in_sidebar && current_path?('projects/graphs#charts') }) do = nav_link(controller: sidebar_repository_paths, unless: -> { current_path?('projects/graphs#charts') }) do
= link_to project_tree_path(@project), class: 'shortcuts-tree qa-project-menu-repo' do = link_to project_tree_path(@project), class: 'shortcuts-tree qa-project-menu-repo' do
.nav-icon-container .nav-icon-container
= sprite_icon('doc-text') = sprite_icon('doc-text')
...@@ -90,11 +77,6 @@ ...@@ -90,11 +77,6 @@
= link_to project_compare_index_path(@project, from: @repository.root_ref, to: current_ref) do = link_to project_compare_index_path(@project, from: @repository.root_ref, to: current_ref) do
= _('Compare') = _('Compare')
- unless should_display_analytics_pages_in_sidebar
= nav_link(path: 'graphs#charts') do
= link_to charts_project_graph_path(@project, current_ref) do
= _('Charts')
= render_if_exists 'projects/sidebar/repository_locked_files' = render_if_exists 'projects/sidebar/repository_locked_files'
- if project_nav_tab? :issues - if project_nav_tab? :issues
...@@ -178,7 +160,7 @@ ...@@ -178,7 +160,7 @@
= number_with_delimiter(@project.open_merge_requests_count) = number_with_delimiter(@project.open_merge_requests_count)
- if project_nav_tab? :pipelines - if project_nav_tab? :pipelines
= nav_link(controller: [:pipelines, :builds, :jobs, :pipeline_schedules, :artifacts], unless: -> { should_display_analytics_pages_in_sidebar && current_path?('projects/pipelines#charts') }) do = nav_link(controller: [:pipelines, :builds, :jobs, :pipeline_schedules, :artifacts], unless: -> { current_path?('projects/pipelines#charts') }) do
= link_to project_pipelines_path(@project), class: 'shortcuts-pipelines qa-link-pipelines rspec-link-pipelines', data: { qa_selector: 'ci_cd_link' } do = link_to project_pipelines_path(@project), class: 'shortcuts-pipelines qa-link-pipelines rspec-link-pipelines', data: { qa_selector: 'ci_cd_link' } do
.nav-icon-container .nav-icon-container
= sprite_icon('rocket') = sprite_icon('rocket')
...@@ -215,12 +197,6 @@ ...@@ -215,12 +197,6 @@
%span %span
= _('Schedules') = _('Schedules')
- if !should_display_analytics_pages_in_sidebar && @project.feature_available?(:builds, current_user) && !@project.empty_repo?
= nav_link(path: 'pipelines#charts') do
= link_to charts_project_pipelines_path(@project), title: _('Charts'), class: 'shortcuts-pipelines-charts' do
%span
= _('Charts')
= render_if_exists 'layouts/nav/sidebar/project_security_link' # EE-specific = render_if_exists 'layouts/nav/sidebar/project_security_link' # EE-specific
- if project_nav_tab? :operations - if project_nav_tab? :operations
...@@ -426,13 +402,6 @@ ...@@ -426,13 +402,6 @@
= link_to project_network_path(@project, current_ref), title: _('Network'), class: 'shortcuts-network' do = link_to project_network_path(@project, current_ref), title: _('Network'), class: 'shortcuts-network' do
= _('Graph') = _('Graph')
- unless should_display_analytics_pages_in_sidebar
-# Shortcut to Repository > Charts (formerly, top-nav item "Graphs")
- unless @project.empty_repo?
%li.hidden
= link_to charts_project_graph_path(@project, current_ref), title: _('Charts'), class: 'shortcuts-repository-charts' do
= _('Charts')
-# Shortcut to Issues > New Issue -# Shortcut to Issues > New Issue
- if project_nav_tab?(:issues) - if project_nav_tab?(:issues)
%li.hidden %li.hidden
......
...@@ -2,9 +2,7 @@ ...@@ -2,9 +2,7 @@
class Analytics::AnalyticsController < Analytics::ApplicationController class Analytics::AnalyticsController < Analytics::ApplicationController
def index def index
if Feature.disabled?(:group_level_productivity_analytics, default_enabled: true) && Gitlab::Analytics.productivity_analytics_enabled? if Feature.disabled?(:group_level_cycle_analytics) && Gitlab::Analytics.cycle_analytics_enabled?
redirect_to analytics_productivity_analytics_path
elsif Feature.disabled?(:group_level_cycle_analytics) && Gitlab::Analytics.cycle_analytics_enabled?
redirect_to analytics_cycle_analytics_path redirect_to analytics_cycle_analytics_path
elsif can?(current_user, :read_instance_statistics) elsif can?(current_user, :read_instance_statistics)
redirect_to instance_statistics_dev_ops_score_index_path redirect_to instance_statistics_dev_ops_score_index_path
......
...@@ -38,7 +38,6 @@ module EE ...@@ -38,7 +38,6 @@ module EE
end end
def group_cycle_analytics_navbar_link(group, current_user) def group_cycle_analytics_navbar_link(group, current_user)
return unless ::Feature.enabled?(:analytics_pages_under_group_analytics_sidebar, group, default_enabled: true)
return unless ::Feature.enabled?(:group_level_cycle_analytics) return unless ::Feature.enabled?(:group_level_cycle_analytics)
return unless group_sidebar_link?(:cycle_analytics) return unless group_sidebar_link?(:cycle_analytics)
...@@ -50,8 +49,6 @@ module EE ...@@ -50,8 +49,6 @@ module EE
end end
def productivity_analytics_navbar_link(group, current_user) def productivity_analytics_navbar_link(group, current_user)
return unless ::Feature.enabled?(:analytics_pages_under_group_analytics_sidebar, group, default_enabled: true)
return unless ::Feature.enabled?(:group_level_productivity_analytics, default_enabled: true)
return unless group_sidebar_link?(:productivity_analytics) return unless group_sidebar_link?(:productivity_analytics)
navbar_sub_item( navbar_sub_item(
...@@ -62,7 +59,6 @@ module EE ...@@ -62,7 +59,6 @@ module EE
end end
def contribution_analytics_navbar_link(group, current_user) def contribution_analytics_navbar_link(group, current_user)
return unless ::Feature.enabled?(:analytics_pages_under_group_analytics_sidebar, group, default_enabled: true)
return unless group_sidebar_link?(:contribution_analytics) return unless group_sidebar_link?(:contribution_analytics)
navbar_sub_item( navbar_sub_item(
...@@ -74,7 +70,6 @@ module EE ...@@ -74,7 +70,6 @@ module EE
end end
def group_insights_navbar_link(group, current_user) def group_insights_navbar_link(group, current_user)
return unless ::Feature.enabled?(:analytics_pages_under_group_analytics_sidebar, group, default_enabled: true)
return unless group_sidebar_link?(:group_insights) return unless group_sidebar_link?(:group_insights)
navbar_sub_item( navbar_sub_item(
...@@ -86,7 +81,6 @@ module EE ...@@ -86,7 +81,6 @@ module EE
end end
def issues_analytics_navbar_link(group, current_user) def issues_analytics_navbar_link(group, current_user)
return unless ::Feature.enabled?(:analytics_pages_under_group_analytics_sidebar, group, default_enabled: true)
return unless group_sidebar_link?(:analytics) return unless group_sidebar_link?(:analytics)
navbar_sub_item( navbar_sub_item(
...@@ -97,7 +91,6 @@ module EE ...@@ -97,7 +91,6 @@ module EE
end end
def insights_navbar_link(project, current_user) def insights_navbar_link(project, current_user)
return unless ::Feature.enabled?(:analytics_pages_under_project_analytics_sidebar, project, default_enabled: true)
return unless project_nav_tab?(:project_insights) return unless project_nav_tab?(:project_insights)
navbar_sub_item( navbar_sub_item(
......
...@@ -11,17 +11,6 @@ module EE ...@@ -11,17 +11,6 @@ module EE
.count .count
end end
override :group_overview_nav_link_paths
def group_overview_nav_link_paths
if ::Feature.enabled?(:analytics_pages_under_group_analytics_sidebar, @group, default_enabled: true)
super
else
super + %w[
groups/insights#show
]
end
end
override :group_nav_link_paths override :group_nav_link_paths
def group_nav_link_paths def group_nav_link_paths
if ::Gitlab::CurrentSettings.should_check_namespace_plan? && can?(current_user, :admin_group, @group) if ::Gitlab::CurrentSettings.should_check_namespace_plan? && can?(current_user, :admin_group, @group)
......
...@@ -4,17 +4,6 @@ module EE ...@@ -4,17 +4,6 @@ module EE
module ProjectsHelper module ProjectsHelper
extend ::Gitlab::Utils::Override extend ::Gitlab::Utils::Override
override :sidebar_projects_paths
def sidebar_projects_paths
if ::Feature.enabled?(:analytics_pages_under_project_analytics_sidebar, @project, default_enabled: true)
super
else
super + %w[
projects/insights#show
]
end
end
override :sidebar_settings_paths override :sidebar_settings_paths
def sidebar_settings_paths def sidebar_settings_paths
super + %w[ super + %w[
......
- page_title _('Productivity Analytics')
- data_attributes = @request_params.valid? ? @request_params.to_data_attributes : @request_params.to_default_data_attributes
#js-productivity-analytics{ data: data_attributes }
.page-title-holder.d-flex.align-items-center
.page-title
= _('Productivity Analytics')
.row-content-block.second-block.d-flex.flex-column.flex-lg-row.mt-3.py-2.px-3
.js-group-project-select-container
.js-search-bar.filter-container.hide
= render 'shared/issuable/search_bar', type: :productivity_analytics
.js-timeframe-container{ data: { start_date: ProductivityAnalytics.start_date } }
.js-productivity-analytics-app-container{ data: { endpoint: analytics_productivity_analytics_path, empty_state_svg_path: image_path('illustrations/productivity-analytics-empty-state.svg'), no_access_svg_path: image_path('illustrations/analytics/no-access.svg') } }
- return unless project_nav_tab?(:project_insights)
= nav_link(path: 'projects/insights#show') do
= link_to project_insights_path(@project), title: _('Insights'), class: 'shortcuts-project-insights', data: { qa_selector: 'project_insights_link' } do
%span= _('Insights')
...@@ -6,19 +6,6 @@ ...@@ -6,19 +6,6 @@
= sprite_icon('chart', size: 24) = sprite_icon('chart', size: 24)
.sidebar-context-title= _('Analytics') .sidebar-context-title= _('Analytics')
%ul.sidebar-top-level-items %ul.sidebar-top-level-items
- if Feature.disabled?(:group_level_productivity_analytics, default_enabled: true) && Gitlab::Analytics.productivity_analytics_enabled?
= nav_link(controller: :productivity_analytics) do
= link_to analytics_productivity_analytics_path, class: 'qa-sidebar-productivity-analytics' do
.nav-icon-container
= sprite_icon('comment')
%span.nav-item-name
= _('Productivity')
%ul.sidebar-sub-level-items.is-fly-out-only
= nav_link(controller: :productivity_analytics, html_options: { class: "fly-out-top-item qa-sidebar-productivity-analytics-fly-out" } ) do
= link_to analytics_productivity_analytics_path do
%strong.fly-out-top-item-name
= _('Productivity')
- if Feature.disabled?(:group_level_cycle_analytics) && Gitlab::Analytics.cycle_analytics_enabled? - if Feature.disabled?(:group_level_cycle_analytics) && Gitlab::Analytics.cycle_analytics_enabled?
= nav_link(controller: :cycle_analytics) do = nav_link(controller: :cycle_analytics) do
= link_to analytics_cycle_analytics_path, class: 'qa-sidebar-cycle-analytics' do = link_to analytics_cycle_analytics_path, class: 'qa-sidebar-cycle-analytics' do
......
...@@ -3,8 +3,6 @@ ...@@ -3,8 +3,6 @@
namespace :analytics do namespace :analytics do
root to: 'analytics#index' root to: 'analytics#index'
resource :productivity_analytics, only: :show, constraints: -> (req) { Feature.disabled?(:group_level_productivity_analytics) && Gitlab::Analytics.productivity_analytics_enabled? }
constraints(-> (req) { Gitlab::Analytics.cycle_analytics_enabled? }) do constraints(-> (req) { Gitlab::Analytics.cycle_analytics_enabled? }) do
resource :cycle_analytics, only: :show, path: 'value_stream_analytics' resource :cycle_analytics, only: :show, path: 'value_stream_analytics'
scope module: :cycle_analytics, as: 'cycle_analytics', path: 'value_stream_analytics' do scope module: :cycle_analytics, as: 'cycle_analytics', path: 'value_stream_analytics' do
......
...@@ -32,7 +32,7 @@ constraints(::Constraints::GroupUrlConstrainer.new) do ...@@ -32,7 +32,7 @@ constraints(::Constraints::GroupUrlConstrainer.new) do
end end
end end
namespace :analytics do namespace :analytics do
resource :productivity_analytics, only: :show, constraints: -> (req) { Feature.enabled?(:group_level_productivity_analytics, default_enabled: true) && Gitlab::Analytics.productivity_analytics_enabled? } resource :productivity_analytics, only: :show, constraints: -> (req) { Gitlab::Analytics.productivity_analytics_enabled? }
resource :cycle_analytics, path: 'value_stream_analytics', only: :show, constraints: -> (req) { Feature.enabled?(:group_level_cycle_analytics) && Gitlab::Analytics.cycle_analytics_enabled? } resource :cycle_analytics, path: 'value_stream_analytics', only: :show, constraints: -> (req) { Feature.enabled?(:group_level_cycle_analytics) && Gitlab::Analytics.cycle_analytics_enabled? }
end end
......
...@@ -8,7 +8,6 @@ describe Analytics::AnalyticsController do ...@@ -8,7 +8,6 @@ describe Analytics::AnalyticsController do
let(:user) { create(:user) } let(:user) { create(:user) }
before do before do
stub_feature_flags(group_level_productivity_analytics: false)
stub_feature_flags(group_level_cycle_analytics: false) stub_feature_flags(group_level_cycle_analytics: false)
sign_in(user) sign_in(user)
...@@ -24,14 +23,6 @@ describe Analytics::AnalyticsController do ...@@ -24,14 +23,6 @@ describe Analytics::AnalyticsController do
expect(response).to redirect_to(analytics_cycle_analytics_path) expect(response).to redirect_to(analytics_cycle_analytics_path)
end end
it 'redirects to productivity analytics' do
stub_feature_flags(Gitlab::Analytics::PRODUCTIVITY_ANALYTICS_FEATURE_FLAG => true)
get :index
expect(response).to redirect_to(analytics_productivity_analytics_path)
end
end end
it 'renders devops score page when all the analytics feature flags are disabled' do it 'renders devops score page when all the analytics feature flags are disabled' do
......
# frozen_string_literal: true
require 'spec_helper'
describe Analytics::ProductivityAnalyticsController do
let(:current_user) { create(:user) }
let(:group) { create :group }
before do
sign_in(current_user) if current_user
stub_feature_flags(group_level_productivity_analytics: false)
stub_licensed_features(productivity_analytics: true)
end
describe 'usage counter' do
before do
group.add_owner(current_user)
end
it 'increments usage counter' do
expect(Gitlab::UsageDataCounters::ProductivityAnalyticsCounter).to receive(:count).with(:views)
get :show, format: :html
expect(response).to be_successful
end
it "doesn't increment the usage counter when JSON request is sent" do
expect(Gitlab::UsageDataCounters::ProductivityAnalyticsCounter).not_to receive(:count).with(:views)
get :show, format: :json, params: { group_id: group }
expect(response).to be_successful
end
end
describe 'GET show' do
subject { get :show }
it 'authorizes for ability to view analytics' do
expect(Ability).to receive(:allowed?).with(current_user, :view_productivity_analytics, :global).and_return(false)
subject
expect(response).to have_gitlab_http_status(:forbidden)
end
it 'renders show template regardless of license' do
stub_licensed_features(productivity_analytics: false)
subject
expect(response).to be_successful
expect(response).to render_template :show
end
it 'renders `404` when feature flag is disabled' do
stub_licensed_features(productivity_analytics: true)
stub_feature_flags(Gitlab::Analytics::PRODUCTIVITY_ANALYTICS_FEATURE_FLAG => false)
get :show
expect(response).to have_gitlab_http_status(:not_found)
end
end
describe 'GET show.json' do
subject { get :show, format: :json, params: params }
let(:params) { {} }
let(:analytics_mock) { instance_double('ProductivityAnalytics') }
before do
merge_requests = double
allow_next_instance_of(ProductivityAnalyticsFinder) do |instance|
allow(instance).to receive(:execute).and_return(merge_requests)
end
allow(ProductivityAnalytics)
.to receive(:new)
.with(merge_requests: merge_requests, sort: params[:sort])
.and_return(analytics_mock)
end
it 'checks for premium license' do
stub_licensed_features(productivity_analytics: false)
subject
expect(response).to have_gitlab_http_status(:forbidden)
end
context 'when invalid params are given' do
let(:params) { { group_id: group, merged_before: 10.days.ago, merged_after: 5.days.ago } }
before do
group.add_owner(current_user)
end
it 'returns 422, unprocessable_entity' do
subject
expect(response).to have_gitlab_http_status(:unprocessable_entity)
expect(response).to match_response_schema('analytics/cycle_analytics/validation_error', dir: 'ee')
end
end
context 'without group_id specified' do
it 'returns 403' do
subject
expect(response).to have_gitlab_http_status(:forbidden)
end
end
context 'with non-existing group_id' do
let(:params) { { group_id: 'SOMETHING_THAT_DOES_NOT_EXIST' } }
it 'renders 404' do
subject
expect(response).to have_gitlab_http_status(:not_found)
end
end
context 'with non-existing project_id' do
let(:params) { { group_id: group, project_id: 'SOMETHING_THAT_DOES_NOT_EXIST' } }
it 'renders 404' do
subject
expect(response).to have_gitlab_http_status(:not_found)
end
end
context 'with group specified' do
let(:params) { { group_id: group } }
before do
group.add_owner(current_user)
end
context 'for list of MRs' do
let!(:merge_request ) { create :merge_request, :merged}
let(:serializer_mock) { instance_double('BaseSerializer') }
before do
allow(BaseSerializer).to receive(:new).with(current_user: current_user).and_return(serializer_mock)
allow(analytics_mock).to receive(:merge_requests_extended).and_return(MergeRequest.all)
allow(serializer_mock).to receive(:represent)
.with(merge_request, {}, ProductivityAnalyticsMergeRequestEntity)
.and_return('mr_representation')
end
it 'serializes whatever analytics returns with ProductivityAnalyticsMergeRequestEntity' do
subject
expect(response.body).to eq '["mr_representation"]'
end
it 'sets pagination headers' do
subject
expect(response.headers['X-Per-Page']).to eq '20'
expect(response.headers['X-Page']).to eq '1'
expect(response.headers['X-Next-Page']).to eq ''
expect(response.headers['X-Prev-Page']).to eq ''
expect(response.headers['X-Total']).to eq '1'
expect(response.headers['X-Total-Pages']).to eq '1'
end
end
context 'for scatterplot charts' do
let(:params) { super().merge({ chart_type: 'scatterplot', metric_type: 'commits_count' }) }
it 'renders whatever analytics returns for scatterplot' do
allow(analytics_mock).to receive(:scatterplot_data).with(type: 'commits_count').and_return('scatterplot_data')
subject
expect(response.body).to eq 'scatterplot_data'
end
end
context 'for histogram charts' do
let(:params) { super().merge({ chart_type: 'histogram', metric_type: 'commits_count' }) }
it 'renders whatever analytics returns for histogram' do
allow(analytics_mock).to receive(:histogram_data).with(type: 'commits_count').and_return('histogram_data')
subject
expect(response.body).to eq 'histogram_data'
end
end
end
end
end
...@@ -17,48 +17,6 @@ describe 'Group active tab' do ...@@ -17,48 +17,6 @@ describe 'Group active tab' do
end end
end end
context 'when `analytics_pages_under_group_analytics_sidebar` feature flag is off' do
before do
stub_feature_flags(analytics_pages_under_group_analytics_sidebar: { enabled: false, thing: group })
end
context 'on group Insights' do
before do
stub_licensed_features(insights: true)
visit group_insights_path(group)
end
it_behaves_like 'page has active tab', _('Group overview')
it_behaves_like 'page has active sub tab', _('Insights')
end
context 'on group Issue Analytics' do
before do
stub_licensed_features(issues_analytics: true)
visit group_issues_analytics_path(group)
end
it_behaves_like 'page has active tab', _('Issues')
it_behaves_like 'page has active sub tab', _('Analytics')
end
context 'on group Contribution Analytics' do
before do
visit group_contribution_analytics_path(group)
end
it_behaves_like 'page has active tab', _('Group overview')
it_behaves_like 'page has active sub tab', _('Contribution')
end
end
context 'when `analytics_pages_under_group_analytics_sidebar` feature flag is on' do
before do
stub_feature_flags(analytics_pages_under_group_analytics_sidebar: { enabled: true, thing: group })
end
context 'on group Insights' do context 'on group Insights' do
before do before do
stub_licensed_features(insights: true) stub_licensed_features(insights: true)
...@@ -100,5 +58,4 @@ describe 'Group active tab' do ...@@ -100,5 +58,4 @@ describe 'Group active tab' do
it_behaves_like 'page has active tab', _('Analytics') it_behaves_like 'page has active tab', _('Analytics')
it_behaves_like 'page has active sub tab', _('Productivity') it_behaves_like 'page has active sub tab', _('Productivity')
end end
end
end end
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
require 'spec_helper' require 'spec_helper'
describe 'ProductivityAnalytics' do describe 'Groups::ProductivityAnalytics' do
let(:user) { create(:user) } let(:user) { create(:user) }
let(:group) { create(:group) } let(:group) { create(:group) }
let(:project) { create(:project, group: group) } let(:project) { create(:project, group: group) }
...@@ -14,13 +14,11 @@ describe 'ProductivityAnalytics' do ...@@ -14,13 +14,11 @@ describe 'ProductivityAnalytics' do
milestone_title: 'user', milestone_title: 'user',
merged_after: Date.yesterday.to_time, merged_after: Date.yesterday.to_time,
merged_before: Date.today.to_time, merged_before: Date.today.to_time,
group_id: group,
project_id: project.full_path project_id: project.full_path
} }
end end
before do before do
stub_feature_flags(group_level_productivity_analytics: false)
stub_licensed_features(productivity_analytics: true) stub_licensed_features(productivity_analytics: true)
sign_in(user) sign_in(user)
...@@ -29,7 +27,7 @@ describe 'ProductivityAnalytics' do ...@@ -29,7 +27,7 @@ describe 'ProductivityAnalytics' do
end end
it 'exposes valid url params in data attributes' do it 'exposes valid url params in data attributes' do
visit analytics_productivity_analytics_path(params) visit group_analytics_productivity_analytics_path(group, params)
element = page.find('#js-productivity-analytics') element = page.find('#js-productivity-analytics')
...@@ -57,7 +55,7 @@ describe 'ProductivityAnalytics' do ...@@ -57,7 +55,7 @@ describe 'ProductivityAnalytics' do
end end
it 'does not expose params in data attributes' do it 'does not expose params in data attributes' do
visit analytics_productivity_analytics_path(params) visit group_analytics_productivity_analytics_path(group, params)
element = page.find('#js-productivity-analytics') element = page.find('#js-productivity-analytics')
......
...@@ -8,8 +8,6 @@ describe 'Groups > Contribution Analytics', :js do ...@@ -8,8 +8,6 @@ describe 'Groups > Contribution Analytics', :js do
let(:empty_project) { create(:project, namespace: group) } let(:empty_project) { create(:project, namespace: group) }
before do before do
stub_feature_flags(analytics_pages_under_group_analytics_sidebar: { enabled: false, thing: group })
group.add_owner(user) group.add_owner(user)
sign_in(user) sign_in(user)
end end
...@@ -18,7 +16,13 @@ describe 'Groups > Contribution Analytics', :js do ...@@ -18,7 +16,13 @@ describe 'Groups > Contribution Analytics', :js do
it 'displays Contribution Analytics' do it 'displays Contribution Analytics' do
visit group_path(group) visit group_path(group)
within('.nav-sidebar') do
find('a', text: 'Analytics').click
within('.sidebar-sub-level-items') do
find('a', text: 'Contribution').click find('a', text: 'Contribution').click
end
end
expect(page).to have_content "Contribution analytics for issues, merge requests and push" expect(page).to have_content "Contribution analytics for issues, merge requests and push"
end end
......
...@@ -12,10 +12,7 @@ describe 'Project active tab' do ...@@ -12,10 +12,7 @@ describe 'Project active tab' do
end end
end end
context 'when `analytics_pages_under_project_analytics_sidebar` feature flag is enabled' do
before do before do
stub_feature_flags(analytics_pages_under_project_analytics_sidebar: { enabled: true, thing: project })
project.add_maintainer(user) project.add_maintainer(user)
sign_in(user) sign_in(user)
end end
...@@ -41,5 +38,4 @@ describe 'Project active tab' do ...@@ -41,5 +38,4 @@ describe 'Project active tab' do
it_behaves_like 'page has active tab', _('Analytics') it_behaves_like 'page has active tab', _('Analytics')
it_behaves_like 'page has active sub tab', _('Code Review') it_behaves_like 'page has active sub tab', _('Code Review')
end end
end
end end
...@@ -13,20 +13,9 @@ describe 'Analytics' do ...@@ -13,20 +13,9 @@ describe 'Analytics' do
let(:user) { create(:user) } let(:user) { create(:user) }
before do before do
stub_feature_flags(group_level_productivity_analytics: false)
login_as(user) login_as(user)
end end
context 'productivity_analytics feature flag is enabled by default' do
it 'succeeds' do
# make sure we call this method for checking the feature availability
expect(Gitlab::Analytics).to receive(:productivity_analytics_enabled?).and_call_original
expect(get('/-/analytics/productivity_analytics')).to route_to('analytics/productivity_analytics#show')
end
end
context 'cycle_analytics feature flag is enabled by default' do context 'cycle_analytics feature flag is enabled by default' do
it 'succeeds' do it 'succeeds' do
expect(Gitlab::Analytics).to receive(:cycle_analytics_enabled?).and_call_original expect(Gitlab::Analytics).to receive(:cycle_analytics_enabled?).and_call_original
...@@ -34,15 +23,5 @@ describe 'Analytics' do ...@@ -34,15 +23,5 @@ describe 'Analytics' do
expect(get('/-/analytics/value_stream_analytics')).to route_to('analytics/cycle_analytics#show') expect(get('/-/analytics/value_stream_analytics')).to route_to('analytics/cycle_analytics#show')
end end
end end
context 'productivity_analytics feature flag is disabled' do
before do
stub_feature_flags(Gitlab::Analytics::PRODUCTIVITY_ANALYTICS_FEATURE_FLAG => false)
end
it 'routes to `not_found`' do
expect(get('/-/analytics/productivity_analytics')).to route_to('application#route_not_found', unmatched_route: '-/analytics/productivity_analytics')
end
end
end end
end end
...@@ -8,15 +8,12 @@ describe 'layouts/nav/sidebar/_analytics' do ...@@ -8,15 +8,12 @@ describe 'layouts/nav/sidebar/_analytics' do
it_behaves_like 'has nav sidebar' it_behaves_like 'has nav sidebar'
before do before do
stub_feature_flags(group_level_productivity_analytics: false)
stub_feature_flags(group_level_cycle_analytics: false) stub_feature_flags(group_level_cycle_analytics: false)
end end
context 'top-level items' do context 'top-level items' do
context 'when feature flags are enabled' do context 'when feature flags are enabled' do
it 'has `Analytics` link' do it 'has `Analytics` link' do
stub_feature_flags(Gitlab::Analytics::PRODUCTIVITY_ANALYTICS_FEATURE_FLAG => true)
render render
expect(rendered).to have_content('Analytics') expect(rendered).to have_content('Analytics')
...@@ -24,19 +21,7 @@ describe 'layouts/nav/sidebar/_analytics' do ...@@ -24,19 +21,7 @@ describe 'layouts/nav/sidebar/_analytics' do
expect(rendered).to match(/<use xlink:href=".+?icons-.+?#chart">/) expect(rendered).to match(/<use xlink:href=".+?icons-.+?#chart">/)
end end
it 'has `Productivity` link' do
stub_feature_flags(Gitlab::Analytics::PRODUCTIVITY_ANALYTICS_FEATURE_FLAG => true)
render
expect(rendered).to have_content('Productivity')
expect(rendered).to include(analytics_productivity_analytics_path)
expect(rendered).to match(/<use xlink:href=".+?icons-.+?#comment">/)
end
it 'has `Value Stream` link' do it 'has `Value Stream` link' do
stub_feature_flags(Gitlab::Analytics::CYCLE_ANALYTICS_FEATURE_FLAG => true)
render render
expect(rendered).to have_content('Value Stream') expect(rendered).to have_content('Value Stream')
...@@ -84,7 +69,6 @@ describe 'layouts/nav/sidebar/_analytics' do ...@@ -84,7 +69,6 @@ describe 'layouts/nav/sidebar/_analytics' do
it 'no analytics links are rendered' do it 'no analytics links are rendered' do
disable_all_analytics_feature_flags disable_all_analytics_feature_flags
expect(rendered).not_to have_content('Productivity')
expect(rendered).not_to have_content('Value Stream') expect(rendered).not_to have_content('Value Stream')
end end
......
...@@ -3406,9 +3406,6 @@ msgstr "" ...@@ -3406,9 +3406,6 @@ msgstr ""
msgid "Changing group path can have unintended side effects." msgid "Changing group path can have unintended side effects."
msgstr "" msgstr ""
msgid "Charts"
msgstr ""
msgid "Charts can't be displayed as the request for data has timed out. %{documentationLink}" msgid "Charts can't be displayed as the request for data has timed out. %{documentationLink}"
msgstr "" msgstr ""
......
...@@ -6,14 +6,6 @@ module QA ...@@ -6,14 +6,6 @@ module QA
module Project module Project
module SubMenus module SubMenus
module Project module Project
def self.included(base)
base.class_eval do
view 'ee/app/views/layouts/nav/_project_insights_link.html.haml' do
element :project_insights_link
end
end
end
def click_project_insights_link def click_project_insights_link
hover_element(:analytics_link) do hover_element(:analytics_link) do
within_submenu(:analytics_sidebar_submenu) do within_submenu(:analytics_sidebar_submenu) do
......
...@@ -10,7 +10,6 @@ module QA ...@@ -10,7 +10,6 @@ module QA
element :group_settings_item element :group_settings_item
element :group_members_item element :group_members_item
element :general_settings_link element :general_settings_link
element :contribution_analytics_link
end end
view 'app/views/layouts/nav/sidebar/_analytics_links.html.haml' do view 'app/views/layouts/nav/sidebar/_analytics_links.html.haml' do
......
...@@ -7,8 +7,6 @@ describe 'Project active tab' do ...@@ -7,8 +7,6 @@ describe 'Project active tab' do
let(:project) { create(:project, :repository) } let(:project) { create(:project, :repository) }
before do before do
stub_feature_flags(analytics_pages_under_project_analytics_sidebar: { enabled: false, thing: project })
project.add_maintainer(user) project.add_maintainer(user)
sign_in(user) sign_in(user)
end end
...@@ -45,7 +43,7 @@ describe 'Project active tab' do ...@@ -45,7 +43,7 @@ describe 'Project active tab' do
it_behaves_like 'page has active tab', 'Repository' it_behaves_like 'page has active tab', 'Repository'
%w(Files Commits Graph Compare Charts Branches Tags).each do |sub_menu| %w(Files Commits Graph Compare Branches Tags).each do |sub_menu|
context "on project Repository/#{sub_menu}" do context "on project Repository/#{sub_menu}" do
before do before do
click_tab(sub_menu) click_tab(sub_menu)
...@@ -124,11 +122,6 @@ describe 'Project active tab' do ...@@ -124,11 +122,6 @@ describe 'Project active tab' do
end end
end end
context 'when `analytics_pages_under_project_analytics_sidebar` feature flag is enabled' do
before do
stub_feature_flags(analytics_pages_under_project_analytics_sidebar: { enabled: true, thing: project })
end
context 'on project Analytics' do context 'on project Analytics' do
before do before do
visit charts_project_graph_path(project, 'master') visit charts_project_graph_path(project, 'master')
...@@ -148,5 +141,4 @@ describe 'Project active tab' do ...@@ -148,5 +141,4 @@ describe 'Project active tab' do
it_behaves_like 'page has active sub tab', _('CI / CD') it_behaves_like 'page has active sub tab', _('CI / CD')
end end
end end
end
end end
...@@ -7,8 +7,6 @@ describe 'User uses shortcuts', :js do ...@@ -7,8 +7,6 @@ describe 'User uses shortcuts', :js do
let(:user) { create(:user) } let(:user) { create(:user) }
before do before do
stub_feature_flags(analytics_pages_under_project_analytics_sidebar: { enabled: false, thing: project })
project.add_maintainer(user) project.add_maintainer(user)
sign_in(user) sign_in(user)
...@@ -119,8 +117,8 @@ describe 'User uses shortcuts', :js do ...@@ -119,8 +117,8 @@ describe 'User uses shortcuts', :js do
find('body').native.send_key('g') find('body').native.send_key('g')
find('body').native.send_key('d') find('body').native.send_key('d')
expect(page).to have_active_navigation('Repository') expect(page).to have_active_navigation(_('Analytics'))
expect(page).to have_active_sub_navigation('Charts') expect(page).to have_active_sub_navigation(_('Repository'))
end end
end end
...@@ -211,18 +209,4 @@ describe 'User uses shortcuts', :js do ...@@ -211,18 +209,4 @@ describe 'User uses shortcuts', :js do
expect(page).to have_active_navigation('Wiki') expect(page).to have_active_navigation('Wiki')
end end
end end
context 'when `analytics_pages_under_project_analytics_sidebar` feature flag is enabled' do
before do
stub_feature_flags(analytics_pages_under_project_analytics_sidebar: { enabled: true, thing: project })
end
it 'redirects to the repository charts page' do
find('body').native.send_key('g')
find('body').native.send_key('d')
expect(page).to have_active_navigation(_('Analytics'))
expect(page).to have_active_sub_navigation(_('Repository'))
end
end
end end
...@@ -166,7 +166,6 @@ describe 'layouts/nav/sidebar/_project' do ...@@ -166,7 +166,6 @@ describe 'layouts/nav/sidebar/_project' do
before do before do
allow(view).to receive(:can?).with(nil, :read_cycle_analytics, project).and_return(read_cycle_analytics) allow(view).to receive(:can?).with(nil, :read_cycle_analytics, project).and_return(read_cycle_analytics)
stub_feature_flags(analytics_pages_under_project_analytics_sidebar: { enabled: false, thing: project })
end end
describe 'when value stream analytics is enabled' do describe 'when value stream analytics is enabled' do
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment