From f330120f90ae8b4892c218324dc01a192839c955 Mon Sep 17 00:00:00 2001 From: Roman Rizzi Date: Tue, 7 May 2019 12:43:47 -0300 Subject: [PATCH] Assigned topics are now ordered by topics.bumped_at (#32) --- plugin.rb | 2 ++ spec/components/topic_query_spec.rb | 8 ++++++++ 2 files changed, 10 insertions(+) diff --git a/plugin.rb b/plugin.rb index 238b2e5..f46d6bd 100644 --- a/plugin.rb +++ b/plugin.rb @@ -150,6 +150,8 @@ after_initialize do WHERE name = 'assigned_to_id' AND value = ?) ", user.id.to_s) + .order("topics.bumped_at DESC") + create_list(:assigned, {}, list) end diff --git a/spec/components/topic_query_spec.rb b/spec/components/topic_query_spec.rb index f5f5402..ded2972 100644 --- a/spec/components/topic_query_spec.rb +++ b/spec/components/topic_query_spec.rb @@ -28,6 +28,14 @@ describe TopicQuery do expect(assigned_messages).to be_empty end + + it 'Returns the results ordered by the bumped_at field' do + @topic.update(bumped_at: 2.weeks.ago) + + assigned_messages = TopicQuery.new(user).list_messages_assigned(user).topics + + expect(assigned_messages).to eq([@private_message, @topic]) + end end describe '#list_private_messages_assigned' do