FIX: Topic.time_to_first_response should include sub-sub-categories (#9349)

This commit is contained in:
Dan Ungureanu
2020-04-04 13:31:34 +03:00
committed by GitHub
parent a8002baaed
commit b9d411a4eb
4 changed files with 37 additions and 27 deletions

View File

@ -2348,6 +2348,20 @@ describe Topic do
expect(Topic.time_to_first_response_total).to eq(1)
end
it "should have results if there's a topic with replies" do
SiteSetting.max_category_nesting = 3
category = Fabricate(:category_with_definition)
subcategory = Fabricate(:category_with_definition, parent_category_id: category.id)
subsubcategory = Fabricate(:category_with_definition, parent_category_id: subcategory.id)
topic = Fabricate(:topic, category: subsubcategory, created_at: 3.hours.ago)
Fabricate(:post, topic: topic, user: topic.user, post_number: 1, created_at: 3.hours.ago)
Fabricate(:post, topic: topic, post_number: 2, created_at: 2.hours.ago)
expect(Topic.time_to_first_response_total(category_id: category.id)).to eq(1)
end
it "should only count regular posts as the first response" do
topic = Fabricate(:topic, created_at: 5.hours.ago)
Fabricate(:post, topic: topic, user: topic.user, post_number: 1, created_at: 5.hours.ago)