Commit 1ac0b06d authored by Peter Leitzen's avatar Peter Leitzen

Merge branch '212226-eliminate-group-vsm-feature-flag-vol-1' into 'master'

Eliminate group_level_cycle_analytics FF

Closes #212226

See merge request gitlab-org/gitlab!28545
parents 260e3c61 88bc2340
......@@ -2,9 +2,7 @@
class Analytics::AnalyticsController < Analytics::ApplicationController
def index
if Feature.disabled?(:group_level_cycle_analytics, default_enabled: true) && Gitlab::Analytics.cycle_analytics_enabled?
redirect_to analytics_cycle_analytics_path
elsif can?(current_user, :read_instance_statistics)
if can?(current_user, :read_instance_statistics)
redirect_to instance_statistics_dev_ops_score_index_path
else
render_404
......
......@@ -38,7 +38,6 @@ module EE
end
def group_cycle_analytics_navbar_link(group, current_user)
return unless ::Feature.enabled?(:group_level_cycle_analytics, default_enabled: true)
return unless group_sidebar_link?(:cycle_analytics)
navbar_sub_item(
......
......@@ -32,15 +32,11 @@ module EE
end
def analytics_nav_url
if ::Feature.disabled?(:group_level_cycle_analytics, default_enabled: true) && ::Gitlab::Analytics.any_features_enabled?
return analytics_root_path
end
if can?(current_user, :read_instance_statistics)
return instance_statistics_root_path
instance_statistics_root_path
else
'errors/not_found'
end
'errors/not_found'
end
private
......@@ -48,8 +44,6 @@ module EE
override :get_dashboard_nav_links
def get_dashboard_nav_links
super.tap do |links|
links << :analytics if ::Feature.disabled?(:group_level_cycle_analytics, default_enabled: true) && ::Gitlab::Analytics.any_features_enabled?
if can?(current_user, :read_operations_dashboard)
links << :environments if ::Feature.enabled?(:environments_dashboard, current_user, default_enabled: true)
links << :operations
......
......@@ -6,19 +6,6 @@
= sprite_icon('chart', size: 24)
.sidebar-context-title= _('Analytics')
%ul.sidebar-top-level-items
- if Feature.disabled?(:group_level_cycle_analytics, default_enabled: true) && Gitlab::Analytics.cycle_analytics_enabled?
= nav_link(controller: :cycle_analytics) do
= link_to analytics_cycle_analytics_path, class: 'qa-sidebar-cycle-analytics' do
.nav-icon-container
= sprite_icon('repeat')
%span.nav-item-name
= _('Value Stream Analytics')
%ul.sidebar-sub-level-items.is-fly-out-only
= nav_link(controller: :cycle_analytics, html_options: { class: "fly-out-top-item qa-sidebar-cycle-analytics-fly-out" } ) do
= link_to analytics_cycle_analytics_path do
%strong.fly-out-top-item-name
= _('Value Stream Analytics')
= render_ce 'layouts/nav/sidebar/instance_statistics_links'
= render 'shared/sidebar_toggle_button'
......@@ -33,7 +33,7 @@ constraints(::Constraints::GroupUrlConstrainer.new) do
end
namespace :analytics do
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, default_enabled: true) && Gitlab::Analytics.cycle_analytics_enabled? }
resource :cycle_analytics, path: 'value_stream_analytics', only: :show, constraints: -> (req) { Gitlab::Analytics.cycle_analytics_enabled? }
end
resource :ldap, only: [] do
......
......@@ -3,28 +3,13 @@
require 'spec_helper'
describe Analytics::AnalyticsController do
include AnalyticsHelpers
let(:user) { create(:user) }
before do
stub_feature_flags(group_level_cycle_analytics: false)
sign_in(user)
disable_all_analytics_feature_flags
end
describe 'GET index' do
describe 'redirects to the first enabled analytics page' do
it 'redirects to value stream analytics' do
stub_feature_flags(Gitlab::Analytics::CYCLE_ANALYTICS_FEATURE_FLAG => true)
get :index
expect(response).to redirect_to(analytics_cycle_analytics_path)
end
end
it 'renders devops score page when all the analytics feature flags are disabled' do
get :index
......
......@@ -3,7 +3,6 @@
require 'spec_helper'
describe 'accessing the analytics workspace' do
include AnalyticsHelpers
let(:user) { create(:user) }
before do
......
......@@ -3,8 +3,6 @@
require 'spec_helper'
describe 'Showing analytics' do
include AnalyticsHelpers
before do
sign_in user if user
end
......@@ -25,7 +23,6 @@ describe 'Showing analytics' do
context 'without access to instance statistics and analytics features' do
before do
disable_all_analytics_feature_flags
stub_application_setting(instance_statistics_visibility_private: true)
end
......
......@@ -3,53 +3,31 @@
require 'spec_helper'
describe DashboardHelper, type: :helper do
include AnalyticsHelpers
let(:user) { build(:user) }
describe '#dashboard_nav_links' do
before do
allow(helper).to receive(:current_user).and_return(user)
stub_feature_flags(group_level_cycle_analytics: false)
end
describe 'analytics' do
context 'when at least one analytics feature is enabled' do
context 'and the user has no access to instance statistics features' do
before do
enable_only_one_analytics_feature_flag
stub_user_permissions_for(:analytics, false)
end
it 'includes analytics' do
expect(helper.dashboard_nav_links).to include(:analytics)
it 'does not include analytics' do
expect(helper.dashboard_nav_links).not_to include(:analytics)
end
end
context 'when all analytics features are disabled' do
context 'and the user has access to instance statistics features' do
before do
disable_all_analytics_feature_flags
stub_user_permissions_for(:analytics, true)
end
context 'and the user has no access to instance statistics features' do
before do
stub_user_permissions_for(:analytics, false)
end
it 'does not include analytics' do
expect(helper.dashboard_nav_links).not_to include(:analytics)
end
end
context 'and the user has access to instance statistics features' do
before do
stub_user_permissions_for(:analytics, true)
end
it 'does include analytics' do
expect(helper.dashboard_nav_links).to include(:analytics)
end
it 'does include analytics' do
expect(helper.dashboard_nav_links).to include(:analytics)
end
end
end
......@@ -239,22 +217,10 @@ describe DashboardHelper, type: :helper do
describe 'analytics_nav_url' do
before do
stub_feature_flags(group_level_cycle_analytics: false)
allow(helper).to receive(:current_user).and_return(user)
end
context 'when any analytics features are enabled' do
it 'returns the analytics root path' do
expect(helper.analytics_nav_url).to match(analytics_root_path)
end
end
context 'when analytics features are disabled' do
before do
disable_all_analytics_feature_flags
end
context 'and user has access to instance statistics features' do
before do
allow(helper).to receive(:can?) { true }
......
# frozen_string_literal: true
# Helper for analytics related features
module AnalyticsHelpers
def disable_all_analytics_feature_flags
Gitlab::Analytics::FEATURE_FLAGS.each do |flag|
stub_feature_flags(flag => false)
end
end
def enable_only_one_analytics_feature_flag
Gitlab::Analytics::FEATURE_FLAGS.each_with_index do |flag, i|
stub_feature_flags(flag => i == 0)
end
end
end
......@@ -3,14 +3,8 @@
require 'spec_helper'
describe 'layouts/nav/sidebar/_analytics' do
include AnalyticsHelpers
it_behaves_like 'has nav sidebar'
before do
stub_feature_flags(group_level_cycle_analytics: false)
end
context 'top-level items' do
context 'when feature flags are enabled' do
it 'has `Analytics` link' do
......@@ -21,14 +15,6 @@ describe 'layouts/nav/sidebar/_analytics' do
expect(rendered).to match(/<use xlink:href=".+?icons-.+?#chart">/)
end
it 'has `Value Stream` link' do
render
expect(rendered).to have_content('Value Stream')
expect(rendered).to include(analytics_cycle_analytics_path)
expect(rendered).to match(/<use xlink:href=".+?icons-.+?#repeat">/)
end
context 'and user has access to instance statistics features' do
before do
allow(view).to receive(:can?) { true }
......@@ -65,46 +51,38 @@ describe 'layouts/nav/sidebar/_analytics' do
end
end
context 'when feature flags are disabled' do
it 'no analytics links are rendered' do
disable_all_analytics_feature_flags
expect(rendered).not_to have_content('Value Stream')
context 'when user has access to instance statistics features' do
before do
allow(view).to receive(:can?) { true }
end
context 'and user has access to instance statistics features' do
before do
allow(view).to receive(:can?) { true }
end
it 'has `DevOps Score` link' do
render
it 'has `DevOps Score` link' do
render
expect(rendered).to have_content('DevOps Score')
expect(rendered).to include(instance_statistics_dev_ops_score_index_path)
expect(rendered).to match(/<use xlink:href=".+?icons-.+?#comment">/)
end
expect(rendered).to have_content('DevOps Score')
expect(rendered).to include(instance_statistics_dev_ops_score_index_path)
expect(rendered).to match(/<use xlink:href=".+?icons-.+?#comment">/)
end
it 'has `Cohorts` link' do
render
it 'has `Cohorts` link' do
render
expect(rendered).to have_content('Cohorts')
expect(rendered).to include(instance_statistics_cohorts_path)
expect(rendered).to match(/<use xlink:href=".+?icons-.+?#users">/)
end
expect(rendered).to have_content('Cohorts')
expect(rendered).to include(instance_statistics_cohorts_path)
expect(rendered).to match(/<use xlink:href=".+?icons-.+?#users">/)
end
end
context 'and user does not have access to instance statistics features' do
before do
allow(view).to receive(:can?) { false }
end
context 'and user does not have access to instance statistics features' do
before do
allow(view).to receive(:can?) { false }
end
it 'no instance statistics links are rendered' do
render
it 'no instance statistics links are rendered' do
render
expect(rendered).not_to have_content('DevOps Score')
expect(rendered).not_to have_content('Cohorts')
end
expect(rendered).not_to have_content('DevOps Score')
expect(rendered).not_to have_content('Cohorts')
end
end
end
......
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