Don't show category descriptions as suggested topics

This commit is contained in:
Neil Lalonde 2013-11-21 16:43:22 -05:00
parent 574a8c92c4
commit bcfbacec16
2 changed files with 13 additions and 0 deletions

View File

@ -7,6 +7,7 @@ class SuggestedTopicsBuilder
def initialize(topic)
@excluded_topic_ids = [topic.id]
@category_id = topic.category_id
@category_topic_ids = Category.pluck(:topic_id).compact
@results = []
end
@ -20,6 +21,7 @@ class SuggestedTopicsBuilder
results = results.where('topics.id NOT IN (?)', @excluded_topic_ids)
.where(closed: false, archived: false, visible: true)
.to_a
.reject { |topic| @category_topic_ids.include?(topic.id) }
unless results.empty?
# Keep track of the ids we've added

View File

@ -90,6 +90,17 @@ describe SuggestedTopicsBuilder do
end
end
context "category definition topics" do
let!(:category) { Fabricate(:category) }
it "doesn't add a category definition topic" do
category.topic_id.should be_present
builder.add_results(Topic)
builder.size.should == 0
builder.should_not be_full
end
end
end