mirror of
https://github.com/redmine/redmine.git
synced 2025-12-16 05:20:28 +01:00
Fix that bulk download raises Errno::EACCES on Windows (#7056).
Patch by Yuichi HARADA. git-svn-id: http://svn.redmine.org/redmine/trunk@19688 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
@@ -280,28 +280,32 @@ class AttachmentTest < ActiveSupport::TestCase
|
||||
|
||||
def test_archive_attachments
|
||||
attachment = Attachment.create!(:file => uploaded_test_file("testfile.txt", ""), :author_id => 1)
|
||||
Tempfile.create('attachments_zip', Rails.root.join('tmp')) do |tempfile|
|
||||
zip_file = Attachment.archive_attachments(tempfile, [attachment])
|
||||
assert_instance_of File, zip_file
|
||||
zip_data = Attachment.archive_attachments([attachment])
|
||||
file_names = []
|
||||
Zip::InputStream.open(StringIO.new(zip_data)) do |io|
|
||||
while (entry = io.get_next_entry)
|
||||
file_names << entry.name
|
||||
end
|
||||
end
|
||||
assert_equal ['testfile.txt'], file_names
|
||||
end
|
||||
|
||||
def test_archive_attachments_without_attachments
|
||||
Tempfile.create('attachments_zip', Rails.root.join('tmp')) do |tempfile|
|
||||
zip_file = Attachment.archive_attachments(tempfile, [])
|
||||
assert_nil zip_file
|
||||
end
|
||||
zip_data = Attachment.archive_attachments([])
|
||||
assert_nil zip_data
|
||||
end
|
||||
|
||||
def test_archive_attachments_should_rename_duplicate_file_names
|
||||
attachment1 = Attachment.create!(:file => uploaded_test_file("testfile.txt", ""), :author_id => 1)
|
||||
attachment2 = Attachment.create!(:file => uploaded_test_file("testfile.txt", ""), :author_id => 1)
|
||||
Tempfile.create('attachments_zip', Rails.root.join('tmp')) do |tempfile|
|
||||
zip_file = Attachment.archive_attachments(tempfile, [attachment1, attachment2])
|
||||
Zip::File.open(zip_file.path) do |z|
|
||||
assert_equal ['testfile.txt', 'testfile(1).txt'], z.map(&:name)
|
||||
zip_data = Attachment.archive_attachments([attachment1, attachment2])
|
||||
file_names = []
|
||||
Zip::InputStream.open(StringIO.new(zip_data)) do |io|
|
||||
while (entry = io.get_next_entry)
|
||||
file_names << entry.name
|
||||
end
|
||||
end
|
||||
assert_equal ['testfile.txt', 'testfile(1).txt'], file_names
|
||||
end
|
||||
|
||||
def test_move_from_root_to_target_directory_should_move_root_files
|
||||
|
||||
Reference in New Issue
Block a user