FIX: scope memoization of category moderation per category (#17786)
This commit is contained in:
parent
8ab6b17c36
commit
ff53f2c7bc
|
@ -112,8 +112,8 @@ class Guardian
|
|||
def is_category_group_moderator?(category)
|
||||
return false unless category
|
||||
return false unless authenticated?
|
||||
|
||||
@is_category_group_moderator ||= begin
|
||||
@is_category_group_moderator ||= {}
|
||||
@is_category_group_moderator[category.id] ||= begin
|
||||
SiteSetting.enable_category_group_moderation? &&
|
||||
category.present? &&
|
||||
category.reviewable_by_group_id.present? &&
|
||||
|
|
|
@ -3953,4 +3953,21 @@ RSpec.describe Guardian do
|
|||
expect(admin.guardian.can_mention_here?).to eq(true)
|
||||
end
|
||||
end
|
||||
|
||||
describe "#is_category_group_moderator" do
|
||||
before do
|
||||
SiteSetting.enable_category_group_moderation = true
|
||||
end
|
||||
|
||||
fab!(:category) { Fabricate(:category) }
|
||||
|
||||
it "should correctly detect category moderation" do
|
||||
group.add(user)
|
||||
category.reviewable_by_group_id = group.id
|
||||
guardian = Guardian.new(user)
|
||||
|
||||
expect(guardian.is_category_group_moderator?(category)).to eq(true)
|
||||
expect(guardian.is_category_group_moderator?(plain_category)).to eq(false)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue