mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
correct random suggested topic selection
This commit is contained in:
@@ -95,21 +95,6 @@ describe SuggestedTopicsBuilder do
|
||||
end
|
||||
end
|
||||
|
||||
context "adding topics that are more than n days old" do
|
||||
let!(:new_topic) { Fabricate(:topic, created_at: 2.days.ago) }
|
||||
let!(:old_topic) { Fabricate(:topic, created_at: 3.years.ago) }
|
||||
|
||||
it "adds topics based on suggested_topics_max_days_old setting" do
|
||||
SiteSetting.suggested_topics_max_days_old = 365
|
||||
|
||||
builder.add_results(Topic)
|
||||
expect(builder.size).to eq(1)
|
||||
expect(builder).not_to be_full
|
||||
expect(builder.excluded_topic_ids.include?(old_topic.id)).to eq(false)
|
||||
expect(builder.excluded_topic_ids.include?(new_topic.id)).to eq(true)
|
||||
end
|
||||
end
|
||||
|
||||
context "category definition topics" do
|
||||
let!(:category) { Fabricate(:category) }
|
||||
|
||||
|
||||
@@ -620,6 +620,26 @@ describe TopicQuery do
|
||||
expect(suggested_topics).to be_blank
|
||||
end
|
||||
|
||||
context 'random suggested' do
|
||||
|
||||
let!(:new_topic) { Fabricate(:topic, created_at: 2.days.ago) }
|
||||
let!(:old_topic) { Fabricate(:topic, created_at: 3.years.ago) }
|
||||
|
||||
it 'respects suggested_topics_max_days_old' do
|
||||
SiteSetting.suggested_topics_max_days_old = 1365
|
||||
tt = topic
|
||||
|
||||
RandomTopicSelector.clear_cache!
|
||||
expect(topic_query.list_suggested_for(tt).topics.length).to eq(2)
|
||||
|
||||
SiteSetting.suggested_topics_max_days_old = 365
|
||||
RandomTopicSelector.clear_cache!
|
||||
|
||||
expect(topic_query.list_suggested_for(tt).topics.length).to eq(1)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
context 'with some existing topics' do
|
||||
let!(:partially_read) { Fabricate(:post, user: creator).topic }
|
||||
let!(:new_topic) { Fabricate(:post, user: creator).topic }
|
||||
|
||||
Reference in New Issue
Block a user