FIX: Support multiple moderation groups on category (#307)

See relevant core PR: https://github.com/discourse/discourse/pull/28655.
This commit is contained in:
Osama Sayegh 2024-09-04 04:37:17 +03:00 committed by GitHub
parent 0157a8ddca
commit 187b8bf19d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 6 additions and 3 deletions

View File

@ -1,3 +1,4 @@
< 3.4.0.beta2-dev: 1bbdfd8f5681171dc3f0e9ea93cd56997dc7938a
< 3.4.0.beta1-dev: dc1ef92be23332a54854751a23b9029463584845 < 3.4.0.beta1-dev: dc1ef92be23332a54854751a23b9029463584845
< 3.3.0.beta2-dev: a18ce6d712fafed286bcc99543dd173110c6dfb8 < 3.3.0.beta2-dev: a18ce6d712fafed286bcc99543dd173110c6dfb8
< 3.3.0.beta1-dev: 526a44644a7b3f0c2a3ba4fc16e72f364e9fce6d < 3.3.0.beta1-dev: 526a44644a7b3f0c2a3ba4fc16e72f364e9fce6d

View File

@ -414,12 +414,13 @@ RSpec.describe "Managing Posts solved status" do
context "with group moderators" do context "with group moderators" do
fab!(:group_user) fab!(:group_user)
let!(:category_moderation_group) do
Fabricate(:category_moderation_group, category: p1.topic.category, group: group_user.group)
end
let(:user_gm) { group_user.user } let(:user_gm) { group_user.user }
let(:group) { group_user.group }
before do before do
SiteSetting.enable_category_group_moderation = true SiteSetting.enable_category_group_moderation = true
p1.topic.category.update!(reviewable_by_group_id: group.id)
sign_in(user_gm) sign_in(user_gm)
end end

View File

@ -46,7 +46,8 @@ describe DiscourseSolved::GuardianExtensions do
it "returns true if the user is a category group moderator for the topic" do it "returns true if the user is a category group moderator for the topic" do
group = Fabricate(:group) group = Fabricate(:group)
group.add(user) group.add(user)
category = Fabricate(:category, reviewable_by_group_id: group.id) category = Fabricate(:category)
Fabricate(:category_moderation_group, category:, group:)
topic.update!(category: category) topic.update!(category: category)
SiteSetting.enable_category_group_moderation = true SiteSetting.enable_category_group_moderation = true
expect(guardian.can_accept_answer?(topic, post)).to eq(true) expect(guardian.can_accept_answer?(topic, post)).to eq(true)