From 7ee660a017d6bed5d0081b314c9c4b2d9bb7d2ee Mon Sep 17 00:00:00 2001 From: Penar Musaraj Date: Fri, 19 Feb 2021 11:03:36 -0500 Subject: [PATCH] FIX: Sort admin dashboard new updates by latest (#12146) --- app/assets/stylesheets/common/admin/dashboard.scss | 1 - lib/discourse_updates.rb | 2 +- spec/components/discourse_updates_spec.rb | 4 ++-- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/app/assets/stylesheets/common/admin/dashboard.scss b/app/assets/stylesheets/common/admin/dashboard.scss index 0e49cb27a41..0271cafa8ae 100644 --- a/app/assets/stylesheets/common/admin/dashboard.scss +++ b/app/assets/stylesheets/common/admin/dashboard.scss @@ -664,7 +664,6 @@ .new-feature-content { padding-right: 0.5em; - align-self: center; .header { font-size: $font-up-1; font-weight: bold; diff --git a/lib/discourse_updates.rb b/lib/discourse_updates.rb index cc1138d1635..4f445787777 100644 --- a/lib/discourse_updates.rb +++ b/lib/discourse_updates.rb @@ -133,7 +133,7 @@ module DiscourseUpdates item["discourse_version"].nil? || Discourse.has_needed_version?(Discourse::VERSION::STRING, item["discourse_version"]) rescue nil end - entries.sort { |item| Time.zone.parse(item["created_at"]) } + entries.sort_by { |item| Time.zone.parse(item["created_at"]).to_i }.reverse end def has_unseen_features?(user_id) diff --git a/spec/components/discourse_updates_spec.rb b/spec/components/discourse_updates_spec.rb index 3bdf7a683a3..6bb8fd27400 100644 --- a/spec/components/discourse_updates_spec.rb +++ b/spec/components/discourse_updates_spec.rb @@ -202,8 +202,8 @@ describe DiscourseUpdates do it 'correctly shows features by Discourse version' do features_with_versions = [ - { "emoji" => "🤾", "title" => "Bells", "created_at" => 40.minutes.ago }, - { "emoji" => "🙈", "title" => "Whistles", "created_at" => 20.minutes.ago, discourse_version: "2.6.0.beta1" }, + { "emoji" => "🤾", "title" => "Bells", "created_at" => 2.days.ago }, + { "emoji" => "🙈", "title" => "Whistles", "created_at" => 120.minutes.ago, discourse_version: "2.6.0.beta1" }, { "emoji" => "🙈", "title" => "Confetti", "created_at" => 15.minutes.ago, discourse_version: "2.7.0.beta2" }, { "emoji" => "🤾", "title" => "Not shown yet", "created_at" => 10.minutes.ago, discourse_version: "2.7.0.beta5" }, { "emoji" => "🤾", "title" => "Not shown yet (beta < stable)", "created_at" => 10.minutes.ago, discourse_version: "2.7.0" },