##// END OF EJS Templates
Merged r14473 (#20278)....
Jean-Philippe Lang -
r14161:1dbb2562934f
parent child
Show More
@@ -294,7 +294,7 class Attachment < ActiveRecord::Base
294
294
295 def self.latest_attach(attachments, filename)
295 def self.latest_attach(attachments, filename)
296 attachments.sort_by(&:created_on).reverse.detect do |att|
296 attachments.sort_by(&:created_on).reverse.detect do |att|
297 att.filename.downcase == filename.downcase
297 filename.casecmp(att.filename) == 0
298 end
298 end
299 end
299 end
300
300
@@ -327,6 +327,13 class AttachmentTest < ActiveSupport::TestCase
327 set_tmp_attachments_directory
327 set_tmp_attachments_directory
328 end
328 end
329
329
330 def test_latest_attach_should_not_error_with_string_with_invalid_encoding
331 string = "width:50\xFE-Image.jpg".force_encoding('UTF-8')
332 assert_equal false, string.valid_encoding?
333
334 Attachment.latest_attach(Attachment.limit(2).to_a, string)
335 end
336
330 def test_thumbnailable_should_be_true_for_images
337 def test_thumbnailable_should_be_true_for_images
331 assert_equal true, Attachment.new(:filename => 'test.jpg').thumbnailable?
338 assert_equal true, Attachment.new(:filename => 'test.jpg').thumbnailable?
332 end
339 end
General Comments 0
You need to be logged in to leave comments. Login now