Assigned topics are now ordered by topics.bumped_at (#32)

approved
#1

Assigned topics are now ordered by topics.bumped_at (#32)

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

GitHub sha: f330120f

1 Like
Approved #2