@@ -294,7 +294,7 class Attachment < ActiveRecord::Base | |||
|
294 | 294 | |
|
295 | 295 | def self.latest_attach(attachments, filename) |
|
296 | 296 | attachments.sort_by(&:created_on).reverse.detect do |att| |
|
297 | att.filename.downcase == filename.downcase | |
|
297 | filename.casecmp(att.filename) == 0 | |
|
298 | 298 | end |
|
299 | 299 | end |
|
300 | 300 |
@@ -327,6 +327,13 class AttachmentTest < ActiveSupport::TestCase | |||
|
327 | 327 | set_tmp_attachments_directory |
|
328 | 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 | 337 | def test_thumbnailable_should_be_true_for_images |
|
331 | 338 | assert_equal true, Attachment.new(:filename => 'test.jpg').thumbnailable? |
|
332 | 339 | end |
General Comments 0
You need to be logged in to leave comments.
Login now