From 06ad13b517941f3b758c0c43055e7ad27e7e1d68 Mon Sep 17 00:00:00 2001 From: Joffrey JAFFEUX Date: Mon, 30 Jan 2023 22:02:32 +0100 Subject: [PATCH] DEV: makes test more deterministic (#20078) `last_message_sent_at` could be equal and as a result the order would be random causing random spec failures in plugins/chat/spec/mailers/user_notifications_spec.rb:182 --- plugins/chat/lib/extensions/user_notifications_extension.rb | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/plugins/chat/lib/extensions/user_notifications_extension.rb b/plugins/chat/lib/extensions/user_notifications_extension.rb index a054b108d85..b64004c3a3b 100644 --- a/plugins/chat/lib/extensions/user_notifications_extension.rb +++ b/plugins/chat/lib/extensions/user_notifications_extension.rb @@ -69,7 +69,10 @@ module Chat::UserNotificationsExtension # Prioritize messages from regular channels over direct messages if channels.any? - channel_notification_text(channels.sort_by(&:last_message_sent_at), dm_users) + channel_notification_text( + channels.sort_by { |channel| [channel.last_message_sent_at, channel.created_at] }, + dm_users, + ) else direct_message_notification_text(dm_users) end