TWEAK: Don't show subcategory topic definitions when viewing a category list.
This commit is contained in:
parent
952426d358
commit
0f52f26587
|
@ -238,7 +238,7 @@ class TopicQuery
|
|||
if options[:no_subcategories]
|
||||
result = result.where('categories.id = ?', category_id)
|
||||
else
|
||||
result = result.where('categories.id = ? or categories.parent_category_id = ?', category_id, category_id)
|
||||
result = result.where('categories.id = ? or (categories.parent_category_id = ? AND categories.topic_id <> topics.id)', category_id, category_id)
|
||||
end
|
||||
result = result.references(:categories)
|
||||
end
|
||||
|
|
|
@ -61,7 +61,7 @@ describe TopicQuery do
|
|||
let!(:subcategory) { Fabricate(:category, parent_category_id: category.id)}
|
||||
|
||||
it "works with subcategories" do
|
||||
TopicQuery.new(moderator, category: category.id).list_latest.topics.size.should == 2
|
||||
TopicQuery.new(moderator, category: category.id).list_latest.topics.size.should == 1
|
||||
TopicQuery.new(moderator, category: subcategory.id).list_latest.topics.size.should == 1
|
||||
TopicQuery.new(moderator, category: category.id, no_subcategories: true).list_latest.topics.size.should == 1
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue