Project

General

Profile

Actions

Defect #34999

closed

The result of Attachment.latest_attach is unstable if attachments have the same timestamp

Added by Pavel Rosický almost 3 years ago. Updated almost 3 years ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
Attachments
Target version:
Start date:
Due date:
% Done:

0%

Estimated time:
Resolution:
Fixed
Affected version:

Description

refs #27780

test_latest_attach_should_support_unicode_case_folding

Failure:
AttachmentTest#test_latest_attach_should_support_unicode_case_folding [c:/redmine/test/unit/attachment_test.rb:488]:
Expected: #<Attachment id: 1990, container_id: nil, container_type: nil, filename: "ā.txt", disk_filename: "210401211700_8b8e5a4d7605340440caaf5211ac5124.TXT", filesize: 32, content_type: "text/plain", digest: "c62e4615bd39e222572f3a1bf7c2132ea1e65b17ec805047bd...", downloads: 0, author_id: 1, created_on: "2021-03-31 19:17:00.000000000 +0000", description: nil, disk_directory: "2021/03">
  Actual: #<Attachment id: 1989, container_id: nil, container_type: nil, filename: "Ā.TXT", disk_filename: "210401211700_8b8e5a4d7605340440caaf5211ac5124.TXT", filesize: 32, content_type: "text/plain", digest: "c62e4615bd39e222572f3a1bf7c2132ea1e65b17ec805047bd...", downloads: 0, author_id: 1, created_on: "2021-03-31 19:17:00.000000000 +0000", description: nil, disk_directory: "2021/03">

on some platforms, sort_by isn't stable
https://bugs.ruby-lang.org/issues/1089
Note that these two attachments have exactly the same timestamp.
https://github.com/redmine/redmine/blob/3e36b5c452210da457cb6c16385551414071693f/app/models/attachment.rb#L373

however, the spec depends on the exact order and it fails if otherwise. Let's make it deterministic. This change doesn't affect the purpose of the test.


Files

fix_attachment_test.diff (696 Bytes) fix_attachment_test.diff Pavel Rosický, 2021-04-01 21:42
fix_attachment_test2.diff (615 Bytes) fix_attachment_test2.diff Pavel Rosický, 2021-04-04 13:49
Actions

Also available in: Atom PDF