FIX: Respect show_category_definitions_in_topic_lists in category lists (#10853)
When that site setting is enabled, the category counts (new/unread) include the subcategory definition topics, but the topics aren't included in the list. This fixes that discrepancy.
This commit is contained in:
parent
3e8561daaf
commit
ddd6c990f6
|
@ -700,11 +700,10 @@ class TopicQuery
|
|||
if options[:no_subcategories]
|
||||
result = result.where('categories.id = ?', category_id)
|
||||
else
|
||||
result = result.where(<<~SQL, subcategory_ids: Category.subcategory_ids(category_id), category_id: category_id)
|
||||
categories.id in (:subcategory_ids) AND (
|
||||
categories.topic_id <> topics.id OR categories.id = :category_id
|
||||
)
|
||||
SQL
|
||||
result = result.where("categories.id IN (?)", Category.subcategory_ids(category_id))
|
||||
if !SiteSetting.show_category_definitions_in_topic_lists
|
||||
result = result.where("categories.topic_id <> topics.id OR categories.id = ?", category_id)
|
||||
end
|
||||
end
|
||||
result = result.references(:categories)
|
||||
|
||||
|
|
|
@ -217,6 +217,11 @@ describe TopicQuery do
|
|||
expect(TopicQuery.new(moderator, category: category.id, no_subcategories: true).list_latest.topics.size).to eq(1)
|
||||
end
|
||||
|
||||
it "shows a subcategory definition topic in its parent list with the right site setting" do
|
||||
SiteSetting.show_category_definitions_in_topic_lists = true
|
||||
expect(TopicQuery.new(moderator, category: category.id).list_latest.topics.size).to eq(2)
|
||||
end
|
||||
|
||||
it "works with subsubcategories" do
|
||||
SiteSetting.max_category_nesting = 3
|
||||
|
||||
|
|
Loading…
Reference in New Issue