FIX: when private messages are disabled in settings, flag modal shouldn't show private message options
This commit is contained in:
parent
043a93dfd5
commit
3cb25b019e
|
@ -9,6 +9,9 @@ module PostGuardian
|
|||
already_did_flagging = taken.any? && (taken & PostActionType.flag_types.values).any?
|
||||
|
||||
if authenticated? && post
|
||||
|
||||
return false if action_key == :notify_moderators && !SiteSetting.enable_private_messages
|
||||
|
||||
# we allow flagging for trust level 1 and higher
|
||||
(is_flag && @user.has_trust_level?(TrustLevel[1]) && not(already_did_flagging)) ||
|
||||
|
||||
|
@ -27,6 +30,9 @@ module PostGuardian
|
|||
# new users can't notify_user because they are not allowed to send private messages
|
||||
not(action_key == :notify_user && !@user.has_trust_level?(TrustLevel[1])) &&
|
||||
|
||||
# can't send private messages if they're disabled globally
|
||||
not(action_key == :notify_user && !SiteSetting.enable_private_messages) &&
|
||||
|
||||
# no voting more than once on single vote topics
|
||||
not(action_key == :vote && opts[:voted_in_topic] && post.topic.has_meta_data_boolean?(:single_vote))
|
||||
end
|
||||
|
|
|
@ -62,6 +62,13 @@ describe Guardian do
|
|||
Guardian.new(user).post_can_act?(post, :off_topic, taken_actions: {PostActionType.types[:spam] => 1}).should be_falsey
|
||||
end
|
||||
|
||||
it "returns false for notify_user if private messages are disabled" do
|
||||
SiteSetting.stubs(:enable_private_messages).returns(false)
|
||||
user.trust_level = TrustLevel[2]
|
||||
Guardian.new(user).post_can_act?(post, :notify_user).should be_falsey
|
||||
Guardian.new(user).post_can_act?(post, :notify_moderators).should be_falsey
|
||||
end
|
||||
|
||||
describe "trust levels" do
|
||||
it "returns true for a new user liking something" do
|
||||
user.trust_level = TrustLevel[0]
|
||||
|
|
Loading…
Reference in New Issue