From 1241660c2c8019991fbd77b4193f9fb081be3716 Mon Sep 17 00:00:00 2001 From: Vinoth Kannan Date: Wed, 26 Apr 2017 21:56:37 +0530 Subject: [PATCH] FIX: 'read' filter in top menu showing new topics --- lib/topic_query.rb | 2 +- spec/components/topic_query_spec.rb | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/topic_query.rb b/lib/topic_query.rb index 4eb4999ab06..741d63d51cf 100644 --- a/lib/topic_query.rb +++ b/lib/topic_query.rb @@ -165,7 +165,7 @@ class TopicQuery def list_read create_list(:read, unordered: true) do |topics| - topics.order('COALESCE(tu.last_visited_at, topics.bumped_at) DESC') + topics.where('tu.last_visited_at IS NOT NULL').order('tu.last_visited_at DESC') end end diff --git a/spec/components/topic_query_spec.rb b/spec/components/topic_query_spec.rb index 65b5196a1c3..4d542032e43 100644 --- a/spec/components/topic_query_spec.rb +++ b/spec/components/topic_query_spec.rb @@ -458,6 +458,8 @@ describe TopicQuery do context 'list_unread' do it 'lists topics correctly' do + new_topic = Fabricate(:post, user: creator).topic + expect(topic_query.list_unread.topics).to eq([]) expect(topic_query.list_read.topics).to match_array([fully_read, partially_read]) end