Edit attachments after upload (#1326).

git-svn-id: http://svn.redmine.org/redmine/trunk@13665 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Jean-Philippe Lang
2014-11-29 13:41:53 +00:00
parent 3c7f638a83
commit 288c014aa7
13 changed files with 236 additions and 5 deletions

View File

@@ -250,6 +250,45 @@ class AttachmentTest < ActiveSupport::TestCase
assert_equal 'text/plain', attachment.content_type
end
def test_update_attachments
attachments = Attachment.where(:id => [2, 3]).to_a
assert Attachment.update_attachments(attachments, {
'2' => {:filename => 'newname.txt', :description => 'New description'},
3 => {:filename => 'othername.txt'}
})
attachment = Attachment.find(2)
assert_equal 'newname.txt', attachment.filename
assert_equal 'New description', attachment.description
attachment = Attachment.find(3)
assert_equal 'othername.txt', attachment.filename
end
def test_update_attachments_with_failure
attachments = Attachment.where(:id => [2, 3]).to_a
assert !Attachment.update_attachments(attachments, {
'2' => {:filename => '', :description => 'New description'},
3 => {:filename => 'othername.txt'}
})
attachment = Attachment.find(3)
assert_equal 'logo.gif', attachment.filename
end
def test_update_attachments_should_sanitize_filename
attachments = Attachment.where(:id => 2).to_a
assert Attachment.update_attachments(attachments, {
2 => {:filename => 'newname?.txt'},
})
attachment = Attachment.find(2)
assert_equal 'newname_.txt', attachment.filename
end
def test_latest_attach
set_fixtures_attachments_directory
a1 = Attachment.find(16)