FEATURE: Support designating multiple groups as mods on category (#28655)

Currently, categories support designating only 1 group as a moderation group on the category. This commit removes the one group limitation and makes it possible to designate multiple groups as mods on a category.

Internal topic: t/124648.
This commit is contained in:
Osama Sayegh
2024-09-04 04:38:46 +03:00
committed by GitHub
parent 7092d88ee4
commit 280adda09c
49 changed files with 388 additions and 273 deletions

View File

@ -4,18 +4,19 @@ RSpec.describe CategorySerializer do
fab!(:user)
fab!(:admin)
fab!(:group)
fab!(:category) { Fabricate(:category, reviewable_by_group_id: group.id) }
fab!(:category)
fab!(:category_moderation_group) { Fabricate(:category_moderation_group, category:, group:) }
it "includes the reviewable by group name if enabled" do
SiteSetting.enable_category_group_moderation = true
json = described_class.new(category, scope: Guardian.new, root: false).as_json
expect(json[:reviewable_by_group_name]).to eq(group.name)
expect(json[:moderating_group_ids]).to eq([group.id])
end
it "doesn't include the reviewable by group name if disabled" do
SiteSetting.enable_category_group_moderation = false
json = described_class.new(category, scope: Guardian.new, root: false).as_json
expect(json[:reviewable_by_group_name]).to be_blank
expect(json[:moderating_group_ids]).to be_blank
end
it "includes custom fields" do

View File

@ -284,12 +284,12 @@ RSpec.describe PostSerializer do
fab!(:topic)
fab!(:group_user)
fab!(:post) { Fabricate(:post, topic: topic) }
before do
SiteSetting.enable_category_group_moderation = true
topic.category.update!(reviewable_by_group_id: group_user.group.id)
fab!(:category_moderation_group) do
Fabricate(:category_moderation_group, category: topic.category, group: group_user.group)
end
before { SiteSetting.enable_category_group_moderation = true }
it "does nothing for regular users" do
expect(serialized_post_for_user(nil)[:group_moderator]).to eq(nil)
end

View File

@ -454,7 +454,10 @@ RSpec.describe TopicViewSerializer do
context "with can_edit" do
fab!(:group_user)
fab!(:category) { Fabricate(:category, reviewable_by_group: group_user.group) }
fab!(:category)
fab!(:category_moderation_group) do
Fabricate(:category_moderation_group, category:, group: group_user.group)
end
fab!(:topic) { Fabricate(:topic, category: category) }
let(:user) { group_user.user }