mirror of
https://github.com/discourse/discourse.git
synced 2025-06-03 19:39:30 +08:00
FIX: staff should not be able to PM groups that "Nobody" can message (#16163)
If a group's messageable_level is set to nobody then staff can't should not be able to send PMs to it. Co-authored-by: Martin Brennan <martin@discourse.org>
This commit is contained in:
@ -336,14 +336,13 @@ describe Guardian do
|
||||
it "respects the group's messageable_level" do
|
||||
Group::ALIAS_LEVELS.each do |level, _|
|
||||
group.update!(messageable_level: Group::ALIAS_LEVELS[level])
|
||||
output = level == :everyone ? true : false
|
||||
user_output = level == :everyone ? true : false
|
||||
admin_output = level != :nobody
|
||||
mod_output = [:nobody, :only_admins].exclude?(level)
|
||||
|
||||
expect(Guardian.new(user).can_send_private_message?(group)).to eq(output)
|
||||
end
|
||||
|
||||
Group::ALIAS_LEVELS.each do |level, _|
|
||||
group.update!(messageable_level: Group::ALIAS_LEVELS[level])
|
||||
expect(Guardian.new(admin).can_send_private_message?(group)).to eq(true)
|
||||
expect(Guardian.new(user).can_send_private_message?(group)).to eq(user_output)
|
||||
expect(Guardian.new(admin).can_send_private_message?(group)).to eq(admin_output)
|
||||
expect(Guardian.new(moderator).can_send_private_message?(group)).to eq(mod_output)
|
||||
end
|
||||
end
|
||||
|
||||
|
Reference in New Issue
Block a user