From 187b8bf19d1611974cf537127513a3135c8ef741 Mon Sep 17 00:00:00 2001 From: Osama Sayegh Date: Wed, 4 Sep 2024 04:37:17 +0300 Subject: [PATCH] FIX: Support multiple moderation groups on category (#307) See relevant core PR: https://github.com/discourse/discourse/pull/28655. --- .discourse-compatibility | 1 + spec/integration/solved_spec.rb | 5 +++-- spec/lib/guardian_extensions_spec.rb | 3 ++- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/.discourse-compatibility b/.discourse-compatibility index e6ec4d0..dedfd44 100644 --- a/.discourse-compatibility +++ b/.discourse-compatibility @@ -1,3 +1,4 @@ +< 3.4.0.beta2-dev: 1bbdfd8f5681171dc3f0e9ea93cd56997dc7938a < 3.4.0.beta1-dev: dc1ef92be23332a54854751a23b9029463584845 < 3.3.0.beta2-dev: a18ce6d712fafed286bcc99543dd173110c6dfb8 < 3.3.0.beta1-dev: 526a44644a7b3f0c2a3ba4fc16e72f364e9fce6d diff --git a/spec/integration/solved_spec.rb b/spec/integration/solved_spec.rb index 3ed6e69..75e4a90 100644 --- a/spec/integration/solved_spec.rb +++ b/spec/integration/solved_spec.rb @@ -414,12 +414,13 @@ RSpec.describe "Managing Posts solved status" do context "with group moderators" do 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(:group) { group_user.group } before do SiteSetting.enable_category_group_moderation = true - p1.topic.category.update!(reviewable_by_group_id: group.id) sign_in(user_gm) end diff --git a/spec/lib/guardian_extensions_spec.rb b/spec/lib/guardian_extensions_spec.rb index f9faccb..2a12c3b 100644 --- a/spec/lib/guardian_extensions_spec.rb +++ b/spec/lib/guardian_extensions_spec.rb @@ -46,7 +46,8 @@ describe DiscourseSolved::GuardianExtensions do it "returns true if the user is a category group moderator for the topic" do group = Fabricate(:group) 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) SiteSetting.enable_category_group_moderation = true expect(guardian.can_accept_answer?(topic, post)).to eq(true)