Skip to content

A platform for community discussion. Free, open, simple.

FIX: `moderators` group wasn't being updated to be messagable by everyone.

Guo Xiang Tanb39d3a863ded
diff --git a/app/models/group.rb b/app/models/group.rb
index 0fadbf9c7ca..a86d60c5812 100644
--- a/app/models/group.rb
+++ b/app/models/group.rb
@@ -268,10 +268,13 @@ class Group < ActiveRecord::Base
# the everyone group is special, it can include non-users so there is no
# way to have the membership in a table
- if name == :everyone
+ case name
+ when :everyone
group.visibility_level = Group.visibility_levels[:owners]
group.save!
return group
+ when :moderators
+ group.update!(messageable_level: ALIAS_LEVELS[:everyone])
end
# Remove people from groups they don't belong in.
diff --git a/spec/models/group_spec.rb b/spec/models/group_spec.rb
index 2b230cadeac..4dce0a96cd3 100644
--- a/spec/models/group_spec.rb
+++ b/spec/models/group_spec.rb
@@ -206,6 +206,14 @@ describe Group do
expect(g.visibility_level).to eq(Group.visibility_levels[:owners])
end
+ it "ensures that the moderators group is messageable by all" do
+ group = Group.find(Group::AUTO_GROUPS[:moderators])
+ group.update!(messageable_level: Group::ALIAS_LEVELS[:nobody])
+ Group.refresh_automatic_group!(:moderators)
+
+ expect(group.reload.messageable_level).to eq(Group::ALIAS_LEVELS[:everyone])
+ end
+
it "does not reset the localized name" do
begin
default_locale = SiteSetting.default_locale