TWEAK: Don't show subcategory topic definitions when viewing a category list.

This commit is contained in:
Robin Ward 2014-06-30 15:22:40 -04:00
parent 952426d358
commit 0f52f26587
2 changed files with 2 additions and 2 deletions

View File

@ -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

View File

@ -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