summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorhttp://jneen.net/ <jneen@jneen.net>2017-07-11 10:57:16 -0700
committerhttp://jneen.net/ <jneen@jneen.net>2017-07-11 10:57:16 -0700
commit2c96aeec65c5652f190e2763fcf02d555091b8d4 (patch)
treeb3c31c5ff51aa5c69b1f096fa227a7481ff55668
parent5fbbadc2bff62b2618ddaf6c37a643975691e356 (diff)
downloadgitlab-ce-bugfix/silence-notifications-when-disabled.tar.gz
add a spec for GlobalPolicy.allowed?(:receive_notifications)bugfix/silence-notifications-when-disabled
-rw-r--r--spec/policies/global_policy_spec.rb25
1 files changed, 25 insertions, 0 deletions
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