FIX: Make sure reset-new for tracked is not limited by per_page count (#13395)

When dismissing new topics for the Tracked filter, the dismiss was
limited to 30 topics which is the default per page count for TopicQuery.
This happened even if you specified which topic IDs you were
selectively dismissing. This PR fixes that bug, and also moves
the per_page_count into a DEFAULT_PER_PAGE_COUNT for the TopicQuery
so it can be stubbed in tests.

Also moves the unused stub_const method into the spec helpers
for cases like this; it is much better to handle this in one place
with an ensure. In a follow up PR I will clean up other specs that
do the same thing and make them use stub_const.
This commit is contained in:
Martin Brennan
2021-06-17 08:20:09 +10:00
committed by GitHub
parent 651b8a23b8
commit 6fe78cd542
5 changed files with 64 additions and 17 deletions

View File

@ -968,7 +968,7 @@ class TopicsController < ApplicationController
Topic.joins(:tags).where(tags: { name: params[:tag_id] })
else
if params[:tracked].to_s == "true"
TopicQuery.tracked_filter(TopicQuery.new(current_user).new_results, current_user.id)
TopicQuery.tracked_filter(TopicQuery.new(current_user).new_results(limit: false), current_user.id)
else
current_user.user_stat.update_column(:new_since, Time.zone.now)
Topic