]> source.dussan.org Git - redmine.git/commitdiff
add test to destroy at unit attachment test.
authorToshi MARUYAMA <marutosijp2@yahoo.co.jp>
Tue, 30 Aug 2011 05:07:31 +0000 (05:07 +0000)
committerToshi MARUYAMA <marutosijp2@yahoo.co.jp>
Tue, 30 Aug 2011 05:07:31 +0000 (05:07 +0000)
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@6762 e93f8b46-1217-0410-a6f0-8f06a7374b81

test/unit/attachment_test.rb

index 0572b05cf08aded4034d9f924d57bb6b1bfef39c..9a0af5c1ba454612f769629ec3de95966fa98569 100644 (file)
@@ -39,6 +39,23 @@ class AttachmentTest < ActiveSupport::TestCase
     assert_equal 59, File.size(a.diskfile)
   end
 
+  def test_destroy
+    a = Attachment.new(:container => Issue.find(1),
+                       :file => uploaded_test_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 '1478adae0d4eb06d35897518540e25d6', a.digest
+    diskfile = a.diskfile
+    assert File.exist?(diskfile)
+    assert_equal 59, File.size(a.diskfile)
+    assert a.destroy
+    assert !File.exist?(diskfile)
+  end
+
   def test_create_should_auto_assign_content_type
     a = Attachment.new(:container => Issue.find(1),
                        :file => uploaded_test_file("testfile.txt", ""),