PERF: make score calculator cheaper when site has long topics

This commit is contained in:
Sam
2016-07-22 09:48:44 +10:00
parent 440558517f
commit 12dc511fea
3 changed files with 61 additions and 43 deletions
+13
View File
@@ -49,6 +49,19 @@ describe ScoreCalculator do
expect(topic.has_summary).to eq(false)
end
it "respects the min_topic_age" do
topic.update_columns(has_summary: true, bumped_at: 1.month.ago)
ScoreCalculator.new(reads: 3).calculate(min_topic_age: 20.days.ago)
expect(topic.has_summary).to eq(true)
end
it "respects the max_topic_length" do
Fabricate(:post, topic_id: topic.id)
topic.update_columns(has_summary: true)
ScoreCalculator.new(reads: 3).calculate(max_topic_length: 1)
expect(topic.has_summary).to eq(true)
end
it "won't update the site settings when the site settings don't match" do
SiteSetting.expects(:summary_likes_required).returns(0)
SiteSetting.expects(:summary_posts_required).returns(1)