summaryrefslogtreecommitdiffstats
path: root/test/unit
diff options
context:
space:
mode:
Diffstat (limited to 'test/unit')
-rw-r--r--test/unit/attachment_test.rb17
1 files changed, 13 insertions, 4 deletions
diff --git a/test/unit/attachment_test.rb b/test/unit/attachment_test.rb
index a8c533238..ae92991f8 100644
--- a/test/unit/attachment_test.rb
+++ b/test/unit/attachment_test.rb
@@ -22,6 +22,19 @@ class AttachmentTest < Test::Unit::TestCase
def setup
end
+
+ def test_create
+ a = Attachment.new(:container => Issue.find(1),
+ :file => test_uploaded_file("testfile.txt", "text/plain"),
+ :author => User.find(1))
+ assert a.save
+ assert_equal 'testfile.txt', a.filename
+ assert_equal 59, a.filesize
+ assert_equal 'text/plain', a.content_type
+ assert_equal 0, a.downloads
+ assert_equal Digest::MD5.hexdigest(test_uploaded_file("testfile.txt", "text/plain").read), a.digest
+ assert File.exist?(a.diskfile)
+ end
def test_diskfilename
assert Attachment.disk_filename("test_file.txt") =~ /^\d{12}_test_file.txt$/
@@ -30,8 +43,4 @@ class AttachmentTest < Test::Unit::TestCase
assert_equal 'f8139524ebb8f32e51976982cd20a85d', Attachment.disk_filename("test_accentué")[13..-1]
assert_equal 'cbb5b0f30978ba03731d61f9f6d10011', Attachment.disk_filename("test_accentué.ça")[13..-1]
end
-
- def test_digest
- assert_equal '1478adae0d4eb06d35897518540e25d6', Attachment.digest(Test::Unit::TestCase.fixture_path + "/files/testfile.txt")
- end
end