mirror of
https://github.com/moparisthebest/mailcatcher
synced 2025-03-11 06:50:12 -04:00
Ensure messages are shown in the order they were recieved
If two messages were received within the same second, they may be sorted by the order they were received. Using `id` as a tie breaker should give a more consistent result. I noticed this issue when writing tests for my Codeception testing framework Mailcatcher module: https://github.com/captbaritone/codeception-mailcatcher-module/issues/13 **Note:** I have not tested this change, but I think it should be correct.
This commit is contained in:
parent
eff638f920
commit
de8a4735a7
@ -69,7 +69,7 @@ module MailCatcher::Mail extend self
|
||||
end
|
||||
|
||||
def messages
|
||||
@messages_query ||= db.prepare "SELECT id, sender, recipients, subject, size, created_at FROM message ORDER BY created_at ASC"
|
||||
@messages_query ||= db.prepare "SELECT id, sender, recipients, subject, size, created_at FROM message ORDER BY created_at, id ASC"
|
||||
@messages_query.execute.map do |row|
|
||||
Hash[row.fields.zip(row)].tap do |message|
|
||||
message["recipients"] &&= ActiveSupport::JSON.decode message["recipients"]
|
||||
|
Loading…
x
Reference in New Issue
Block a user