Project

General

Profile

Defect #27780 » 27780.patch

Go MAEDA, 2020-10-22 16:29

View differences:

app/models/attachment.rb
342 342

  
343 343
  def self.latest_attach(attachments, filename)
344 344
    attachments.sort_by(&:created_on).reverse.detect do |att|
345
      filename.casecmp(att.filename) == 0
345
      filename.casecmp?(att.filename)
346 346
    end
347 347
  end
348 348

  
test/unit/attachment_test.rb
464 464
    Attachment.latest_attach(Attachment.limit(2).to_a, string)
465 465
  end
466 466

  
467
  def test_latest_attach_should_support_unicode_case_folding
468
    a_capital = Attachment.create!(
469
      :author => User.find(1),
470
      :file => mock_file(:filename => 'Ā.TXT')
471
    )
472
    a_small = Attachment.create!(
473
      :author => User.find(1),
474
      :file => mock_file(:filename => 'ā.txt')
475
    )
476

  
477
    assert_equal(a_small, Attachment.latest_attach([a_capital, a_small], 'Ā.TXT'))
478
  end
479

  
467 480
  def test_thumbnailable_should_be_true_for_images
468 481
    skip unless convert_installed?
469 482
    assert_equal true, Attachment.new(:filename => 'test.jpg').thumbnailable?
(2-2/2)