summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2014-12-05 08:35:00 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2014-12-05 08:35:00 +0000
commit56edfcf6e92c4eb19f2654fb17b44b0c4ae50c21 (patch)
treef530c4f9f617d5f462ea871807485cd27610166f
parent89da75623d52de8b68ace6c219636ffad23e732e (diff)
downloadredmine-56edfcf6e92c4eb19f2654fb17b44b0c4ae50c21.tar.gz
redmine-56edfcf6e92c4eb19f2654fb17b44b0c4ae50c21.zip
Adds some Attachment tests.
git-svn-id: http://svn.redmine.org/redmine/trunk@13709 e93f8b46-1217-0410-a6f0-8f06a7374b81
-rw-r--r--test/unit/attachment_test.rb22
1 files changed, 22 insertions, 0 deletions
diff --git a/test/unit/attachment_test.rb b/test/unit/attachment_test.rb
index 29c433f7b..d97ce93c7 100644
--- a/test/unit/attachment_test.rb
+++ b/test/unit/attachment_test.rb
@@ -67,6 +67,16 @@ class AttachmentTest < ActiveSupport::TestCase
assert_equal 59, File.size(a.diskfile)
end
+ def test_create_should_clear_content_type_if_too_long
+ a = Attachment.new(:container => Issue.find(1),
+ :file => uploaded_test_file("testfile.txt", "text/plain"),
+ :author => User.find(1),
+ :content_type => 'a'*300)
+ assert a.save
+ a.reload
+ assert_nil a.content_type
+ end
+
def test_copy_should_preserve_attributes
a = Attachment.find(1)
copy = a.copy
@@ -180,6 +190,12 @@ class AttachmentTest < ActiveSupport::TestCase
assert_equal "test.png (Cool image)", a.title
end
+ def test_new_attachment_should_be_editable_by_authot
+ user = User.find(1)
+ a = Attachment.new(:author => user)
+ assert_equal true, a.editable?(user)
+ end
+
def test_prune_should_destroy_old_unattached_attachments
Attachment.create!(:file => uploaded_test_file("testfile.txt", ""), :author_id => 1, :created_on => 2.days.ago)
Attachment.create!(:file => uploaded_test_file("testfile.txt", ""), :author_id => 1, :created_on => 2.days.ago)
@@ -331,6 +347,12 @@ class AttachmentTest < ActiveSupport::TestCase
assert File.exists?(thumbnail)
end
end
+
+ def test_thumbnail_should_return_nil_if_generation_fails
+ Redmine::Thumbnail.stubs(:generate).raises(SystemCallError, 'Something went wrong')
+ attachment = Attachment.find(16)
+ assert_nil attachment.thumbnail
+ end
else
puts '(ImageMagick convert not available)'
end