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

https://meta.discourse.org/t/custom-flag-not-showing-text/76244
This commit is contained in:
Guo Xiang Tan 2017-12-19 10:13:58 +08:00
parent 1abc276451
commit b39d3a863d
2 changed files with 12 additions and 1 deletions

View File

@ -268,10 +268,13 @@ class Group < ActiveRecord::Base
# the everyone group is special, it can include non-users so there is no # the everyone group is special, it can include non-users so there is no
# way to have the membership in a table # way to have the membership in a table
if name == :everyone case name
when :everyone
group.visibility_level = Group.visibility_levels[:owners] group.visibility_level = Group.visibility_levels[:owners]
group.save! group.save!
return group return group
when :moderators
group.update!(messageable_level: ALIAS_LEVELS[:everyone])
end end
# Remove people from groups they don't belong in. # Remove people from groups they don't belong in.

View File

@ -206,6 +206,14 @@ describe Group do
expect(g.visibility_level).to eq(Group.visibility_levels[:owners]) expect(g.visibility_level).to eq(Group.visibility_levels[:owners])
end 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 it "does not reset the localized name" do
begin begin
default_locale = SiteSetting.default_locale default_locale = SiteSetting.default_locale