Commit c052ed1e13fc0de68b9372b5747ce9bb1696adae

Authored by Victor Costa
1 parent ebb43808

rails3: fix tests related to upload_file

app/models/uploaded_file.rb
... ... @@ -33,7 +33,7 @@ class UploadedFile < Article
33 33 end
34 34  
35 35 def thumbnail_path
36   - self.image? ? self.full_filename(:display).to_s.gsub(Rails.root.join('public'), '') : nil
  36 + self.image? ? self.full_filename(:display).to_s.gsub(Rails.root.join('public').to_s, '') : nil
37 37 end
38 38  
39 39 def display_title
... ...
test/unit/uploaded_file_test.rb
... ... @@ -101,7 +101,7 @@ class UploadedFileTest < ActiveSupport::TestCase
101 101 up = build(UploadedFile, :filename => 'fake_filename.png')
102 102 up.valid?
103 103  
104   - assert_match /#{UploadedFile.max_size.to_humanreadable}/, up.errors[:size]
  104 + assert_match /#{UploadedFile.max_size.to_humanreadable}/, up.errors[:size].first
105 105 end
106 106  
107 107 should 'display link to download of non-image files' do
... ... @@ -128,8 +128,7 @@ class UploadedFileTest < ActiveSupport::TestCase
128 128 assert upload.errors[:title]
129 129  
130 130 upload.title = '+' * 60; upload.valid?
131   - assert !upload.errors[:title]
132   -
  131 + assert_blank upload.errors[:title]
133 132 end
134 133  
135 134 should 'always provide a display title' do
... ... @@ -151,7 +150,7 @@ class UploadedFileTest < ActiveSupport::TestCase
151 150 should 'use name as title by default but cut down the title' do
152 151 upload = build(UploadedFile, :uploaded_data => fixture_file_upload('/files/AGENDA_CULTURA_-_FESTA_DE_VAQUEIROS_PONTO_DE_SERRA_PRETA_BAIXA.txt'))
153 152 upload.valid?
154   - assert_nil upload.errors[:title]
  153 + assert_blank upload.errors[:title]
155 154 end
156 155  
157 156 should 'create thumbnails after processing jobs' do
... ...
vendor/plugins/monkey_patches/attachment_fu/init.rb
1 1 # Monkey patch to rewrite attachment_fu's logic where no image with parent can
2 2 # be thumbnailable.
3 3  
4   -Technoweenie::AttachmentFu.module_eval do
  4 +Technoweenie::AttachmentFu::InstanceMethods.module_eval do
5 5 def thumbnailable?
6 6 image? && !is_thumbnail?
7 7 end
... ...
vendor/plugins/monkey_patches/init.rb
1 1 require File.join(File.dirname(__FILE__), 'attachment_fu_validates_attachment/init')
  2 +require File.join(File.dirname(__FILE__), 'attachment_fu/init')
... ...