Commit 5c75519d authored by Magdalena Frankiewicz's avatar Magdalena Frankiewicz

Remove read_instance_statistics policy

As Cohorts and DevOps Report were previously under
instance statistics and available to admin or
or everybody that policy made sense.
Currently Cohorts and DevOps Report are
under Admin panel, therefore that policy is no
longer needed.
parent 766745ca
......@@ -58,10 +58,6 @@ module DashboardHelper
links += [:activity, :milestones]
end
if can?(current_user, :read_instance_statistics)
links << :analytics
end
links
end
end
......
......@@ -47,7 +47,7 @@ module NavHelper
end
def has_extra_nav_icons?
Gitlab::Sherlock.enabled? || can?(current_user, :read_instance_statistics) || current_user.admin?
Gitlab::Sherlock.enabled? || current_user.admin?
end
def page_has_markdown?
......
......@@ -98,7 +98,6 @@ class GlobalPolicy < BasePolicy
rule { admin }.policy do
enable :read_custom_attribute
enable :update_custom_attribute
enable :read_instance_statistics
end
# We can't use `read_statistics` because the user may have different permissions for different projects
......
......@@ -10,28 +10,6 @@ RSpec.describe DashboardHelper, type: :helper do
allow(helper).to receive(:current_user).and_return(user)
end
describe 'analytics' do
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
end
end
describe 'operations dashboard link' do
context 'when the feature is available on the license' do
context 'and the user is authenticated' do
......@@ -160,11 +138,9 @@ RSpec.describe DashboardHelper, type: :helper do
def stub_user_permissions_for(feature, enabled)
allow(helper).to receive(:can?).with(user, :read_cross_project).and_return(false)
can_read_instance_statistics = enabled && feature == :analytics
can_read_operations_dashboard = enabled && feature == :operations
can_read_instance_security_dashboard = enabled && feature == :security
allow(helper).to receive(:can?).with(user, :read_instance_statistics).and_return(can_read_instance_statistics)
allow(helper).to receive(:can?).with(user, :read_operations_dashboard).and_return(can_read_operations_dashboard)
allow_next_instance_of(InstanceSecurityDashboard) do |dashboard|
allow(helper).to(
......
......@@ -7,10 +7,10 @@ module RuboCop
#
# @example
# # bad
# root to: redirect('/-/instance_statistics/dev_ops_report')
# root to: redirect('/-/autocomplete/users')
#
# # good
# root to: redirect('-/instance_statistics/dev_ops_report')
# root to: redirect('-/autocomplete/users')
#
class AvoidRouteRedirectLeadingSlash < RuboCop::Cop::Cop
......
......@@ -370,24 +370,6 @@ RSpec.describe GlobalPolicy do
end
end
describe 'read instance statistics' do
context 'regular user' do
it { is_expected.to be_disallowed(:read_instance_statistics) }
end
context 'admin', :enable_admin_mode do
let(:current_user) { create(:admin) }
it { is_expected.to be_allowed(:read_instance_statistics) }
end
context 'anonymous' do
let(:current_user) { nil }
it { is_expected.not_to be_allowed(:read_instance_statistics) }
end
end
describe 'slash commands' do
context 'regular user' do
it { is_expected.to be_allowed(:use_slash_commands) }
......
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