summaryrefslogtreecommitdiffstats
path: root/test/unit/attachment_test.rb
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2017-04-03 11:54:29 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2017-04-03 11:54:29 +0000
commitf0e5437d27f008379b8523ce2b54d697e5e9be94 (patch)
tree94dcd61f23892e2118af3b75aace179c0d540265 /test/unit/attachment_test.rb
parentd65e920307c89e9ad7a1e7f85865ab7198f89cd7 (diff)
downloadredmine-f0e5437d27f008379b8523ce2b54d697e5e9be94.tar.gz
redmine-f0e5437d27f008379b8523ce2b54d697e5e9be94.zip
Reuse existing identical disk files for new attachments (#25215).
Patch by Jens Kraemer. git-svn-id: http://svn.redmine.org/redmine/trunk@16458 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'test/unit/attachment_test.rb')
-rw-r--r--test/unit/attachment_test.rb8
1 files changed, 6 insertions, 2 deletions
diff --git a/test/unit/attachment_test.rb b/test/unit/attachment_test.rb
index 16f02e51a..0b188f8a1 100644
--- a/test/unit/attachment_test.rb
+++ b/test/unit/attachment_test.rb
@@ -94,6 +94,10 @@ class AttachmentTest < ActiveSupport::TestCase
end
def test_copy_should_preserve_attributes
+
+ # prevent re-use of data from other attachments with equal contents
+ Attachment.where('id <> 1').destroy_all
+
a = Attachment.find(1)
copy = a.copy
@@ -220,14 +224,14 @@ class AttachmentTest < ActiveSupport::TestCase
assert_equal 'text/plain', a.content_type
end
- def test_identical_attachments_at_the_same_time_should_not_overwrite
+ def test_identical_attachments_should_reuse_same_file
a1 = Attachment.create!(:container => Issue.find(1),
:file => uploaded_test_file("testfile.txt", ""),
:author => User.find(1))
a2 = Attachment.create!(:container => Issue.find(1),
:file => uploaded_test_file("testfile.txt", ""),
:author => User.find(1))
- assert a1.disk_filename != a2.disk_filename
+ assert_equal a1.diskfile, a2.diskfile
end
def test_filename_should_be_basenamed