mirror of
https://github.com/codeninjasllc/discourse.git
synced 2024-11-23 23:58:31 -05:00
FIX: Can view best filter while logged in
This commit is contained in:
parent
721ec5002d
commit
6106057328
2 changed files with 12 additions and 3 deletions
|
@ -265,6 +265,15 @@ class TopicView
|
|||
@filtered_posts.by_newest.with_user.first(25)
|
||||
end
|
||||
|
||||
|
||||
def current_post_ids
|
||||
@current_post_ids ||= if @posts.is_a?(Array)
|
||||
@posts.map {|p| p.id }
|
||||
else
|
||||
@posts.pluck(:post_number)
|
||||
end
|
||||
end
|
||||
|
||||
protected
|
||||
|
||||
def read_posts_set
|
||||
|
@ -275,7 +284,7 @@ class TopicView
|
|||
|
||||
post_numbers = PostTiming.select(:post_number)
|
||||
.where(topic_id: @topic.id, user_id: @user.id)
|
||||
.where(post_number: @posts.pluck(:post_number))
|
||||
.where(post_number: current_post_ids)
|
||||
.pluck(:post_number)
|
||||
|
||||
post_numbers.each {|pn| result << pn}
|
||||
|
|
|
@ -24,7 +24,7 @@ describe TopicView do
|
|||
let!(:p3) { Fabricate(:post, topic: topic, user: first_poster, percent_rank: 0 )}
|
||||
|
||||
it "it can find the best responses" do
|
||||
best2 = TopicView.new(topic.id, nil, best: 2)
|
||||
best2 = TopicView.new(topic.id, coding_horror, best: 2)
|
||||
best2.posts.count.should == 2
|
||||
best2.posts[0].id.should == p2.id
|
||||
best2.posts[1].id.should == p3.id
|
||||
|
@ -36,7 +36,7 @@ describe TopicView do
|
|||
best = TopicView.new(topic.id, nil, best: 99)
|
||||
best.posts.count.should == 2
|
||||
best.filtered_posts_count.should == 3
|
||||
|
||||
best.current_post_ids.should =~ [p2.id, p3.id]
|
||||
end
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue