diff options
author | Bob Van Landuyt <bob@vanlanduyt.co> | 2018-07-25 17:36:08 +0200 |
---|---|---|
committer | Bob Van Landuyt <bob@vanlanduyt.co> | 2018-07-27 14:14:47 +0200 |
commit | 61b0e8ca0b2a1c50aeee318c7e42c40fd0816108 (patch) | |
tree | e8ee1bf5900919792526c04cf55e2b9647eb917b /spec/policies | |
parent | fb6375a57633ba633760e5542739c544bf5595aa (diff) | |
download | gitlab-ce-61b0e8ca0b2a1c50aeee318c7e42c40fd0816108.tar.gz |
Spec instance statistics
Diffstat (limited to 'spec/policies')
-rw-r--r-- | spec/policies/global_policy_spec.rb | 34 |
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 |