From c052ed1e13fc0de68b9372b5747ce9bb1696adae Mon Sep 17 00:00:00 2001 From: Victor Costa Date: Fri, 17 Jan 2014 15:29:49 -0300 Subject: [PATCH] rails3: fix tests related to upload_file --- app/models/uploaded_file.rb | 2 +- test/unit/uploaded_file_test.rb | 7 +++---- vendor/plugins/monkey_patches/attachment_fu/init.rb | 2 +- vendor/plugins/monkey_patches/init.rb | 1 + 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/app/models/uploaded_file.rb b/app/models/uploaded_file.rb index 196539c..e25096b 100644 --- a/app/models/uploaded_file.rb +++ b/app/models/uploaded_file.rb @@ -33,7 +33,7 @@ class UploadedFile < Article end def thumbnail_path - self.image? ? self.full_filename(:display).to_s.gsub(Rails.root.join('public'), '') : nil + self.image? ? self.full_filename(:display).to_s.gsub(Rails.root.join('public').to_s, '') : nil end def display_title diff --git a/test/unit/uploaded_file_test.rb b/test/unit/uploaded_file_test.rb index 7f74a63..798df13 100644 --- a/test/unit/uploaded_file_test.rb +++ b/test/unit/uploaded_file_test.rb @@ -101,7 +101,7 @@ class UploadedFileTest < ActiveSupport::TestCase up = build(UploadedFile, :filename => 'fake_filename.png') up.valid? - assert_match /#{UploadedFile.max_size.to_humanreadable}/, up.errors[:size] + assert_match /#{UploadedFile.max_size.to_humanreadable}/, up.errors[:size].first end should 'display link to download of non-image files' do @@ -128,8 +128,7 @@ class UploadedFileTest < ActiveSupport::TestCase assert upload.errors[:title] upload.title = '+' * 60; upload.valid? - assert !upload.errors[:title] - + assert_blank upload.errors[:title] end should 'always provide a display title' do @@ -151,7 +150,7 @@ class UploadedFileTest < ActiveSupport::TestCase should 'use name as title by default but cut down the title' do upload = build(UploadedFile, :uploaded_data => fixture_file_upload('/files/AGENDA_CULTURA_-_FESTA_DE_VAQUEIROS_PONTO_DE_SERRA_PRETA_BAIXA.txt')) upload.valid? - assert_nil upload.errors[:title] + assert_blank upload.errors[:title] end should 'create thumbnails after processing jobs' do diff --git a/vendor/plugins/monkey_patches/attachment_fu/init.rb b/vendor/plugins/monkey_patches/attachment_fu/init.rb index 5c131d4..1edbc9e 100644 --- a/vendor/plugins/monkey_patches/attachment_fu/init.rb +++ b/vendor/plugins/monkey_patches/attachment_fu/init.rb @@ -1,7 +1,7 @@ # Monkey patch to rewrite attachment_fu's logic where no image with parent can # be thumbnailable. -Technoweenie::AttachmentFu.module_eval do +Technoweenie::AttachmentFu::InstanceMethods.module_eval do def thumbnailable? image? && !is_thumbnail? end diff --git a/vendor/plugins/monkey_patches/init.rb b/vendor/plugins/monkey_patches/init.rb index 4eb6fce..eb34bbd 100644 --- a/vendor/plugins/monkey_patches/init.rb +++ b/vendor/plugins/monkey_patches/init.rb @@ -1 +1,2 @@ require File.join(File.dirname(__FILE__), 'attachment_fu_validates_attachment/init') +require File.join(File.dirname(__FILE__), 'attachment_fu/init') -- libgit2 0.21.2