diff options
author | Bob Van Landuyt <bob@vanlanduyt.co> | 2018-07-25 18:36:08 +0300 |
---|---|---|
committer | Bob Van Landuyt <bob@vanlanduyt.co> | 2018-07-27 16:54:28 +0300 |
commit | 00b5f5475f7f35620d01033711cdb8e2f5fff5c8 (patch) | |
tree | 128cc055ea7a8233ca23b0b78fd2a7dc646d063b /spec/policies/global_policy_spec.rb | |
parent | 702a09c18365cbaa88edb8396339a61a73f29d23 (diff) |
Spec instance statistics
Diffstat (limited to 'spec/policies/global_policy_spec.rb')
-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 |