mirror of
https://github.com/codeninjasllc/discourse.git
synced 2024-11-23 15:48:43 -05:00
FIX: error when sending a private message to a group in some cases
This commit is contained in:
parent
df565da3b3
commit
fd853e0776
2 changed files with 13 additions and 0 deletions
|
@ -42,6 +42,7 @@ class Group < ActiveRecord::Base
|
|||
}
|
||||
|
||||
AUTO_GROUP_IDS = Hash[*AUTO_GROUPS.to_a.flatten.reverse]
|
||||
STAFF_GROUPS = [:admins, :moderators, :staff]
|
||||
|
||||
ALIAS_LEVELS = {
|
||||
:nobody => 0,
|
||||
|
@ -370,6 +371,10 @@ class Group < ActiveRecord::Base
|
|||
Group.mentionable(user).where(id: group_id).exists?
|
||||
end
|
||||
|
||||
def staff?
|
||||
STAFF_GROUPS.include?(self.name.to_sym)
|
||||
end
|
||||
|
||||
protected
|
||||
|
||||
def name_format_validator
|
||||
|
|
|
@ -202,6 +202,14 @@ describe Guardian do
|
|||
it "returns false if target is not staff" do
|
||||
expect(Guardian.new(user).can_send_private_message?(another_user)).to be_falsey
|
||||
end
|
||||
|
||||
it "returns true if target is a staff group" do
|
||||
Group::STAFF_GROUPS.each do |name|
|
||||
g = Group[name]
|
||||
g.alias_level = Group::ALIAS_LEVELS[:everyone]
|
||||
expect(Guardian.new(user).can_send_private_message?(g)).to be_truthy
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in a new issue