diff options
Diffstat (limited to 'test/unit/attachment_test.rb')
-rw-r--r-- | test/unit/attachment_test.rb | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/test/unit/attachment_test.rb b/test/unit/attachment_test.rb index 4e90ee03e..144fb5425 100644 --- a/test/unit/attachment_test.rb +++ b/test/unit/attachment_test.rb @@ -234,6 +234,23 @@ class AttachmentTest < ActiveSupport::TestCase assert_not_equal a1.diskfile, a2.diskfile end + def test_identical_attachments_created_in_same_transaction_should_not_end_up_unreadable + attachments = [] + Project.transaction do + 3.times do + a = Attachment.create!( + :container => Issue.find(1), :author => User.find(1), + :file => mock_file(:filename => 'foo', :content => 'abcde') + ) + attachments << a + end + end + attachments.each do |a| + assert a.readable? + end + assert_equal 1, attachments.map(&:diskfile).uniq.size + end + def test_filename_should_be_basenamed a = Attachment.new(:file => mock_file(:original_filename => "path/to/the/file")) assert_equal 'file', a.filename |