summaryrefslogtreecommitdiff
path: root/spec/policies/global_policy_spec.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/policies/global_policy_spec.rb')
-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