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
This commit is contained in:
Joffrey JAFFEUX 2023-01-30 22:02:32 +01:00 committed by GitHub
parent a4c32e3970
commit 06ad13b517
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 1 deletions

View File

@ -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