diff options
-rw-r--r-- | app/controllers/request_controller.rb | 4 | ||||
-rw-r--r-- | spec/integration/download_request_spec.rb | 6 |
2 files changed, 6 insertions, 4 deletions
diff --git a/app/controllers/request_controller.rb b/app/controllers/request_controller.rb index ac92801b9..e5950c41d 100644 --- a/app/controllers/request_controller.rb +++ b/app/controllers/request_controller.rb @@ -926,10 +926,12 @@ class RequestController < ApplicationController Zip::ZipFile.open(file_path, Zip::ZipFile::CREATE) do |zipfile| file_info = make_request_summary_file(info_request) zipfile.get_output_stream(file_info[:filename]) { |f| f.puts(file_info[:data]) } + message_index = 0 info_request.incoming_messages.each do |message| next unless message.user_can_view?(authenticated_user) + message_index += 1 message.get_attachments_for_display.each do |attachment| - filename = "#{attachment.url_part_number}_#{attachment.display_filename}" + filename = "#{message_index}_#{attachment.url_part_number}_#{attachment.display_filename}" zipfile.get_output_stream(filename) { |f| f.puts(attachment.body) } end end diff --git a/spec/integration/download_request_spec.rb b/spec/integration/download_request_spec.rb index 84dda9a1b..2af98c271 100644 --- a/spec/integration/download_request_spec.rb +++ b/spec/integration/download_request_spec.rb @@ -155,15 +155,15 @@ describe 'when making a zipfile available' do inspect_zip_download(request_owner, info_request) do |zip| zip.count.should == 3 # the message plus two "hello-world.txt" files - zip.read('2_hello world.txt').should match('Second hello') - zip.read('3_hello world.txt').should match('First hello') + zip.read('2_2_hello world.txt').should match('Second hello') + zip.read('2_3_hello world.txt').should match('First hello') end sleep_and_receive_mail('incoming-request-attachment-unknown-extension.email', info_request) inspect_zip_download(request_owner, info_request) do |zip| zip.count.should == 4 # the message plus two "hello-world.txt" files, and the new attachment - zip.read('2_hello.qwglhm').should match('This is an unusual') + zip.read('3_2_hello.qwglhm').should match('This is an unusual') end end |