@@ -67,6 +67,16 class AttachmentTest < ActiveSupport::TestCase | |||||
67 | assert_equal 59, File.size(a.diskfile) |
|
67 | assert_equal 59, File.size(a.diskfile) | |
68 | end |
|
68 | end | |
69 |
|
69 | |||
|
70 | def test_create_should_clear_content_type_if_too_long | |||
|
71 | a = Attachment.new(:container => Issue.find(1), | |||
|
72 | :file => uploaded_test_file("testfile.txt", "text/plain"), | |||
|
73 | :author => User.find(1), | |||
|
74 | :content_type => 'a'*300) | |||
|
75 | assert a.save | |||
|
76 | a.reload | |||
|
77 | assert_nil a.content_type | |||
|
78 | end | |||
|
79 | ||||
70 | def test_copy_should_preserve_attributes |
|
80 | def test_copy_should_preserve_attributes | |
71 | a = Attachment.find(1) |
|
81 | a = Attachment.find(1) | |
72 | copy = a.copy |
|
82 | copy = a.copy | |
@@ -180,6 +190,12 class AttachmentTest < ActiveSupport::TestCase | |||||
180 | assert_equal "test.png (Cool image)", a.title |
|
190 | assert_equal "test.png (Cool image)", a.title | |
181 | end |
|
191 | end | |
182 |
|
192 | |||
|
193 | def test_new_attachment_should_be_editable_by_authot | |||
|
194 | user = User.find(1) | |||
|
195 | a = Attachment.new(:author => user) | |||
|
196 | assert_equal true, a.editable?(user) | |||
|
197 | end | |||
|
198 | ||||
183 | def test_prune_should_destroy_old_unattached_attachments |
|
199 | def test_prune_should_destroy_old_unattached_attachments | |
184 | Attachment.create!(:file => uploaded_test_file("testfile.txt", ""), :author_id => 1, :created_on => 2.days.ago) |
|
200 | Attachment.create!(:file => uploaded_test_file("testfile.txt", ""), :author_id => 1, :created_on => 2.days.ago) | |
185 | Attachment.create!(:file => uploaded_test_file("testfile.txt", ""), :author_id => 1, :created_on => 2.days.ago) |
|
201 | Attachment.create!(:file => uploaded_test_file("testfile.txt", ""), :author_id => 1, :created_on => 2.days.ago) | |
@@ -331,6 +347,12 class AttachmentTest < ActiveSupport::TestCase | |||||
331 | assert File.exists?(thumbnail) |
|
347 | assert File.exists?(thumbnail) | |
332 | end |
|
348 | end | |
333 | end |
|
349 | end | |
|
350 | ||||
|
351 | def test_thumbnail_should_return_nil_if_generation_fails | |||
|
352 | Redmine::Thumbnail.stubs(:generate).raises(SystemCallError, 'Something went wrong') | |||
|
353 | attachment = Attachment.find(16) | |||
|
354 | assert_nil attachment.thumbnail | |||
|
355 | end | |||
334 | else |
|
356 | else | |
335 | puts '(ImageMagick convert not available)' |
|
357 | puts '(ImageMagick convert not available)' | |
336 | end |
|
358 | end |
General Comments 0
You need to be logged in to leave comments.
Login now