Commit 98ec4b86 authored by mfluharty's avatar mfluharty

Also check for group coverage reports feature flag

Repository analytics has only group coverage reports for now
parent 74115b2d
# frozen_string_literal: true
class Groups::Analytics::RepositoryAnalyticsController < Groups::Analytics::ApplicationController
check_feature_flag Gitlab::Analytics::GROUP_COVERAGE_REPORTS_FEATURE_FLAG
layout 'group'
before_action :load_group
before_action -> { check_feature_availability!(:group_coverage_reports) }
before_action -> { check_feature_availability!(:group_repository_analytics) }
before_action -> { authorize_view_by_action!(:read_group_repository_analytics) }
......
......@@ -137,6 +137,7 @@ module EE
end
def group_repository_analytics_navbar_link(group, current_user)
return unless ::Gitlab::Analytics.group_coverage_reports_enabled?
return unless group_sidebar_link?(:repository_analytics)
navbar_sub_item(
......
......@@ -26,7 +26,7 @@ constraints(::Constraints::GroupUrlConstrainer.new) do
resource :productivity_analytics, only: :show, constraints: -> (req) { Gitlab::Analytics.productivity_analytics_enabled? }
resources :coverage_reports, only: :index, constraints: -> (req) { Gitlab::Analytics.group_coverage_reports_enabled? }
resource :merge_request_analytics, only: :show, constraints: -> (req) { Gitlab::Analytics.group_merge_request_analytics_enabled? }
resource :repository_analytics, only: [:show]
resource :repository_analytics, only: :show, constraints: -> (req) { Gitlab::Analytics.group_coverage_reports_enabled? }
feature_default_enabled = Gitlab::Analytics.feature_enabled_by_default?(Gitlab::Analytics::CYCLE_ANALYTICS_FEATURE_FLAG)
constrainer = ::Constraints::FeatureConstrainer.new(Gitlab::Analytics::CYCLE_ANALYTICS_FEATURE_FLAG, default_enabled: feature_default_enabled)
......
......@@ -5,11 +5,13 @@ require 'spec_helper'
RSpec.describe Groups::Analytics::RepositoryAnalyticsController do
let_it_be(:current_user) { create(:user) }
let_it_be(:group) { create :group }
let_it_be(:feature_flag_name) { Gitlab::Analytics::GROUP_COVERAGE_REPORTS_FEATURE_FLAG }
let_it_be(:feature_name) { :group_repository_analytics }
before do
sign_in(current_user)
stub_feature_flags(feature_flag_name => true)
stub_licensed_features(feature_name => true)
end
......@@ -30,6 +32,14 @@ RSpec.describe Groups::Analytics::RepositoryAnalyticsController do
it { is_expected.to have_gitlab_http_status(:forbidden) }
end
context 'when feature flag is off' do
before do
stub_feature_flags(feature_flag_name => false)
end
it { is_expected.to have_gitlab_http_status(:not_found) }
end
context 'when the user has no access to the group' do
before do
current_user.group_members.delete_all
......
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