TopicView/PostSerializer should be able to handle topics without categories
This commit is contained in:
parent
150e83d2a6
commit
8f140b8903
|
@ -431,7 +431,7 @@ class TopicView
|
||||||
|
|
||||||
def category_group_moderator_user_ids
|
def category_group_moderator_user_ids
|
||||||
@category_group_moderator_user_ids ||= begin
|
@category_group_moderator_user_ids ||= begin
|
||||||
if SiteSetting.enable_category_group_moderation? && @topic.category&.reviewable_by_group&.present?
|
if SiteSetting.enable_category_group_moderation? && @topic.category&.reviewable_by_group.present?
|
||||||
posts_user_ids = Set.new(@posts.map(&:user_id))
|
posts_user_ids = Set.new(@posts.map(&:user_id))
|
||||||
Set.new(
|
Set.new(
|
||||||
@topic.category.reviewable_by_group.group_users.where(user_id: posts_user_ids).pluck('distinct user_id')
|
@topic.category.reviewable_by_group.group_users.where(user_id: posts_user_ids).pluck('distinct user_id')
|
||||||
|
|
|
@ -379,4 +379,24 @@ describe TopicViewSerializer do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
context "viewing private messages when enable_category_group_moderation is enabled" do
|
||||||
|
fab!(:pm_topic) do
|
||||||
|
Fabricate(:private_message_topic, topic_allowed_users: [
|
||||||
|
Fabricate.build(:topic_allowed_user, user: user),
|
||||||
|
Fabricate.build(:topic_allowed_user, user: admin)
|
||||||
|
])
|
||||||
|
end
|
||||||
|
fab!(:post) { Fabricate(:post, topic: pm_topic) }
|
||||||
|
|
||||||
|
before do
|
||||||
|
SiteSetting.enable_category_group_moderation = true
|
||||||
|
end
|
||||||
|
|
||||||
|
# Ensure having enable_category_group_moderation turned on doesn't break private messages
|
||||||
|
it "should return posts" do
|
||||||
|
json = serialize_topic(pm_topic, user)
|
||||||
|
expect(json[:post_stream][:posts]).to be_present
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue