From 2c96aeec65c5652f190e2763fcf02d555091b8d4 Mon Sep 17 00:00:00 2001 From: "http://jneen.net/" Date: Tue, 11 Jul 2017 10:57:16 -0700 Subject: add a spec for GlobalPolicy.allowed?(:receive_notifications) --- spec/policies/global_policy_spec.rb | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/spec/policies/global_policy_spec.rb b/spec/policies/global_policy_spec.rb index 93ce111d5ac..edad30b304a 100644 --- a/spec/policies/global_policy_spec.rb +++ b/spec/policies/global_policy_spec.rb @@ -30,4 +30,29 @@ describe GlobalPolicy, models: true do end end end + + describe "receive_notifications" do + it { is_expected.to be_allowed(:receive_notifications) } + + context "a blocked user" do + let(:current_user) { create(:user, state: :blocked) } + + it { is_expected.to be_disallowed(:receive_notifications) } + end + + context "an internal user" do + let(:current_user) { User.ghost } + + it { is_expected.to be_disallowed(:receive_notifications) } + end + + context "a user with globally disabled notification settings" do + before do + current_user.global_notification_setting.level = :disabled + current_user.global_notification_setting.save! + end + + it { is_expected.to be_disallowed(:receive_notifications) } + end + end end -- cgit v1.2.1