summaryrefslogtreecommitdiffstats
path: root/test/unit/attachment_test.rb
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2012-01-20 17:56:28 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2012-01-20 17:56:28 +0000
commit8a3623733fa2ef879bb2a3f4355e0ce0df49b278 (patch)
treeaabdb9f4aa05eff33a8f19551aa1fa8558ebc813 /test/unit/attachment_test.rb
parente347fba11aea87a6bdc9ab6aeaca742d13a8c613 (diff)
downloadredmine-8a3623733fa2ef879bb2a3f4355e0ce0df49b278.tar.gz
redmine-8a3623733fa2ef879bb2a3f4355e0ce0df49b278.zip
Copy attachments on issue and project copy (#3055).
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@8676 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'test/unit/attachment_test.rb')
-rw-r--r--test/unit/attachment_test.rb35
1 files changed, 35 insertions, 0 deletions
diff --git a/test/unit/attachment_test.rb b/test/unit/attachment_test.rb
index 56474b051..0486529b3 100644
--- a/test/unit/attachment_test.rb
+++ b/test/unit/attachment_test.rb
@@ -52,6 +52,25 @@ class AttachmentTest < ActiveSupport::TestCase
assert_equal 59, File.size(a.diskfile)
end
+ def test_size_should_be_validated_for_new_file
+ with_settings :attachment_max_size => 0 do
+ a = Attachment.new(:container => Issue.find(1),
+ :file => uploaded_test_file("testfile.txt", "text/plain"),
+ :author => User.find(1))
+ assert !a.save
+ end
+ end
+
+ def test_size_should_not_be_validated_when_copying
+ a = Attachment.create!(:container => Issue.find(1),
+ :file => uploaded_test_file("testfile.txt", "text/plain"),
+ :author => User.find(1))
+ with_settings :attachment_max_size => 0 do
+ copy = a.copy
+ assert copy.save
+ end
+ end
+
def test_destroy
a = Attachment.new(:container => Issue.find(1),
:file => uploaded_test_file("testfile.txt", "text/plain"),
@@ -69,6 +88,22 @@ class AttachmentTest < ActiveSupport::TestCase
assert !File.exist?(diskfile)
end
+ def test_destroy_should_not_delete_file_referenced_by_other_attachment
+ a = Attachment.create!(:container => Issue.find(1),
+ :file => uploaded_test_file("testfile.txt", "text/plain"),
+ :author => User.find(1))
+ diskfile = a.diskfile
+
+ copy = a.copy
+ copy.save!
+
+ assert File.exists?(diskfile)
+ a.destroy
+ assert File.exists?(diskfile)
+ copy.destroy
+ assert !File.exists?(diskfile)
+ end
+
def test_create_should_auto_assign_content_type
a = Attachment.new(:container => Issue.find(1),
:file => uploaded_test_file("testfile.txt", ""),