summaryrefslogtreecommitdiff
path: root/spec/policies
diff options
context:
space:
mode:
authorFilipa Lacerda <filipa@gitlab.com>2018-08-01 15:17:47 +0000
committerFilipa Lacerda <filipa@gitlab.com>2018-08-01 15:17:47 +0000
commitea6fc714bb0306ac8ca56b5dafe4b6777aafe5fc (patch)
tree5d9673f0e526acbdb3285147024064f89d45dc23 /spec/policies
parent47244ad5ea4e887ecb6dffa9f7b96846adbf4b6f (diff)
parent29dd1c14db6899c3858ca906e076c7b7fbbaa0e2 (diff)
downloadgitlab-ce-ea6fc714bb0306ac8ca56b5dafe4b6777aafe5fc.tar.gz
Merge branch '41416-making-instance-wide-data-tools-more-accessible' into 'master'
Resolve "Making instance-wide data tools more accessible" Closes #41416 and #48507 See merge request gitlab-org/gitlab-ce!20874
Diffstat (limited to 'spec/policies')
-rw-r--r--spec/policies/global_policy_spec.rb34
1 files changed, 34 insertions, 0 deletions
diff --git a/spec/policies/global_policy_spec.rb b/spec/policies/global_policy_spec.rb
index a2047b54deb..30d68e7dc9d 100644
--- a/spec/policies/global_policy_spec.rb
+++ b/spec/policies/global_policy_spec.rb
@@ -180,4 +180,38 @@ describe GlobalPolicy do
end
end
end
+
+ describe 'read instance statistics' do
+ context 'regular user' do
+ it { is_expected.to be_allowed(:read_instance_statistics) }
+
+ context 'when instance statistics are set to private' do
+ before do
+ stub_application_setting(instance_statistics_visibility_private: true)
+ end
+
+ it { is_expected.not_to be_allowed(:read_instance_statistics) }
+ end
+ end
+
+ context 'admin' do
+ let(:current_user) { create(:admin) }
+
+ it { is_expected.to be_allowed(:read_instance_statistics) }
+
+ context 'when instance statistics are set to private' do
+ before do
+ stub_application_setting(instance_statistics_visibility_private: true)
+ end
+
+ it { is_expected.to be_allowed(:read_instance_statistics) }
+ end
+ end
+
+ context 'anonymous' do
+ let(:current_user) { nil }
+
+ it { is_expected.not_to be_allowed(:read_instance_statistics) }
+ end
+ end
end