From a9363f6c3926d5a8cba8db79176c1b76bc4118e7 Mon Sep 17 00:00:00 2001 From: Louise Crow Date: Wed, 14 Aug 2013 14:56:21 +0100 Subject: Rewrite download spec Make it an integration spec so we don't need to touch the internals so much. --- spec/integration/download_request_spec.rb | 60 +++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 spec/integration/download_request_spec.rb (limited to 'spec/integration/download_request_spec.rb') diff --git a/spec/integration/download_request_spec.rb b/spec/integration/download_request_spec.rb new file mode 100644 index 000000000..563efbf50 --- /dev/null +++ b/spec/integration/download_request_spec.rb @@ -0,0 +1,60 @@ +require File.expand_path(File.dirname(__FILE__) + '/../spec_helper') +require File.expand_path(File.dirname(__FILE__) + '/alaveteli_dsl') + +describe 'when making a zipfile available' do + + def inspect_zip_download(session, info_request) + session.get_via_redirect "request/#{info_request.url_title}/download" + session.response.should be_success + Tempfile.open('download') do |f| + f.binmode + f.write(session.response.body) + f.flush + Zip::ZipFile::open(f) do |zip| + yield zip + end + end + end + + def sleep_and_receive_mail(name, info_request) + # The path of the zip file is based on the hash of the timestamp of the last request + # in the thread, so we wait for a second to make sure this one will have a different + # timestamp than the previous. + sleep 1 + receive_incoming_mail(name, info_request.incoming_email) + end + + it "should update the contents of the zipfile when the request changes" do + + info_request = FactoryGirl.create(:info_request_with_incoming) + request_owner = login(info_request.user) + inspect_zip_download(request_owner, info_request) do |zip| + zip.count.should == 1 # just the message + expected = 'This is a plain-text version of the Freedom of Information request "Example Title"' + zip.read('correspondence.txt').should match expected + end + + sleep_and_receive_mail('incoming-request-two-same-name.email', info_request) + + 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') + 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') + end + end + + + it 'should successfully make a zipfile for an external request' do + info_request = info_requests(:external_request) + get_via_redirect "request/#{info_request.url_title}/download" + response.should be_success + end + +end -- cgit v1.2.3 From d65804b7d8d2138b4570b26449321e1a9bb847fb Mon Sep 17 00:00:00 2001 From: Louise Crow Date: Wed, 21 Aug 2013 14:01:22 +0100 Subject: Remove hidden incoming messages from correspondence.txt Adds a spec for what we want to see - no message text in correspondence.txt, and no attachments. Refactors the simple_correspondence templates to make it clearer that these are doing the same job as the html.erb ones, for text. --- spec/integration/download_request_spec.rb | 34 +++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) (limited to 'spec/integration/download_request_spec.rb') diff --git a/spec/integration/download_request_spec.rb b/spec/integration/download_request_spec.rb index 563efbf50..33e90d435 100644 --- a/spec/integration/download_request_spec.rb +++ b/spec/integration/download_request_spec.rb @@ -50,6 +50,40 @@ describe 'when making a zipfile available' do end end + context 'when an incoming message is made "requester_only"' do + it 'should not include the incoming message or attachments in a download of the entire request + by a non-request owner', :focus => true do + + # Non-owner can download zip with incoming and attachments + non_owner = login(FactoryGirl.create(:user)) + info_request = FactoryGirl.create(:info_request_with_incoming_attachments) + inspect_zip_download(non_owner, info_request) do |zip| + zip.count.should == 3 + zip.read('correspondence.txt').should match('hereisthetext') + end + + # Admin makes the incoming message requester only + admin = login(FactoryGirl.create(:admin_user)) + post_data = {:incoming_message => {:prominence => 'requester_only', + :prominence_reason => 'boring'}} + admin.post_via_redirect "/en/admin/incoming/update/#{info_request.incoming_messages.first.id}", post_data + admin.response.should be_success + + inspect_zip_download(non_owner, info_request) do |zip| + zip.count.should == 1 + correspondence_text = zip.read('correspondence.txt') + correspondence_text.should_not match('hereisthetext') + expected_text = 'This message has been hidden. boring' + correspondence_text.should match(expected_text) + end + + end + + it 'should include the incoming message and attachments in a download of the entire request + by the owner' + + end + it 'should successfully make a zipfile for an external request' do info_request = info_requests(:external_request) -- cgit v1.2.3 From 64139935c8de9c08d3c68e9ef9810af5af8a2131 Mon Sep 17 00:00:00 2001 From: Louise Crow Date: Thu, 22 Aug 2013 10:32:24 +0100 Subject: Make external request download spec more specific. --- spec/integration/download_request_spec.rb | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'spec/integration/download_request_spec.rb') diff --git a/spec/integration/download_request_spec.rb b/spec/integration/download_request_spec.rb index 33e90d435..62e38c607 100644 --- a/spec/integration/download_request_spec.rb +++ b/spec/integration/download_request_spec.rb @@ -85,10 +85,11 @@ describe 'when making a zipfile available' do end - it 'should successfully make a zipfile for an external request' do - info_request = info_requests(:external_request) - get_via_redirect "request/#{info_request.url_title}/download" - response.should be_success + it 'should successfully make a zipfile for an external request', :focus => true do + external_request = FactoryGirl.create(:external_request) + user = login(FactoryGirl.create(:user)) + inspect_zip_download(user, external_request){ |zip| zip.count.should == 1 } + end end end -- cgit v1.2.3 From 2fdf336adb60e9010952a5fb7f593febc3fdffa2 Mon Sep 17 00:00:00 2001 From: Louise Crow Date: Thu, 22 Aug 2013 10:34:39 +0100 Subject: Make absence of htmltopdf converter more explicit. We're testing the code path where there is no converter here. --- spec/integration/download_request_spec.rb | 99 ++++++++++++++++--------------- 1 file changed, 52 insertions(+), 47 deletions(-) (limited to 'spec/integration/download_request_spec.rb') diff --git a/spec/integration/download_request_spec.rb b/spec/integration/download_request_spec.rb index 62e38c607..8af1c9ff1 100644 --- a/spec/integration/download_request_spec.rb +++ b/spec/integration/download_request_spec.rb @@ -24,66 +24,71 @@ describe 'when making a zipfile available' do receive_incoming_mail(name, info_request.incoming_email) end - it "should update the contents of the zipfile when the request changes" do - - info_request = FactoryGirl.create(:info_request_with_incoming) - request_owner = login(info_request.user) - inspect_zip_download(request_owner, info_request) do |zip| - zip.count.should == 1 # just the message - expected = 'This is a plain-text version of the Freedom of Information request "Example Title"' - zip.read('correspondence.txt').should match expected - end - - sleep_and_receive_mail('incoming-request-two-same-name.email', info_request) + context 'when no html to pdf converter is supplied' 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') + before do + AlaveteliConfiguration.stub!(:html_to_pdf_command).and_return('') end - sleep_and_receive_mail('incoming-request-attachment-unknown-extension.email', info_request) + it "should update the contents of the zipfile when the request changes" do - 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') - end - end + info_request = FactoryGirl.create(:info_request_with_incoming) + request_owner = login(info_request.user) + inspect_zip_download(request_owner, info_request) do |zip| + zip.count.should == 1 # just the message + expected = 'This is a plain-text version of the Freedom of Information request "Example Title"' + zip.read('correspondence.txt').should match expected + end - context 'when an incoming message is made "requester_only"' do - it 'should not include the incoming message or attachments in a download of the entire request - by a non-request owner', :focus => true do + sleep_and_receive_mail('incoming-request-two-same-name.email', info_request) - # Non-owner can download zip with incoming and attachments - non_owner = login(FactoryGirl.create(:user)) - info_request = FactoryGirl.create(:info_request_with_incoming_attachments) - inspect_zip_download(non_owner, info_request) do |zip| - zip.count.should == 3 - zip.read('correspondence.txt').should match('hereisthetext') + 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') end - # Admin makes the incoming message requester only - admin = login(FactoryGirl.create(:admin_user)) - post_data = {:incoming_message => {:prominence => 'requester_only', - :prominence_reason => 'boring'}} - admin.post_via_redirect "/en/admin/incoming/update/#{info_request.incoming_messages.first.id}", post_data - admin.response.should be_success - - inspect_zip_download(non_owner, info_request) do |zip| - zip.count.should == 1 - correspondence_text = zip.read('correspondence.txt') - correspondence_text.should_not match('hereisthetext') - expected_text = 'This message has been hidden. boring' - correspondence_text.should match(expected_text) - 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') + end end - it 'should include the incoming message and attachments in a download of the entire request - by the owner' + context 'when an incoming message is made "requester_only"' do + it 'should not include the incoming message or attachments in a download of the entire request + by a non-request owner' do + + # Non-owner can download zip with incoming and attachments + non_owner = login(FactoryGirl.create(:user)) + info_request = FactoryGirl.create(:info_request_with_incoming_attachments) + inspect_zip_download(non_owner, info_request) do |zip| + zip.count.should == 3 + zip.read('correspondence.txt').should match('hereisthetext') + end + + # Admin makes the incoming message requester only + admin = login(FactoryGirl.create(:admin_user)) + post_data = {:incoming_message => {:prominence => 'requester_only', + :prominence_reason => 'boring'}} + admin.post_via_redirect "/en/admin/incoming/update/#{info_request.incoming_messages.first.id}", post_data + admin.response.should be_success + + inspect_zip_download(non_owner, info_request) do |zip| + zip.count.should == 1 + correspondence_text = zip.read('correspondence.txt') + correspondence_text.should_not match('hereisthetext') + expected_text = 'This message has been hidden. boring' + correspondence_text.should match(expected_text) + end - end + end + it 'should include the incoming message and attachments in a download of the entire request + by the owner' + + end it 'should successfully make a zipfile for an external request', :focus => true do external_request = FactoryGirl.create(:external_request) -- cgit v1.2.3 From fd0c811cc4e01435ca89a419a521f6ac31a858b1 Mon Sep 17 00:00:00 2001 From: Louise Crow Date: Thu, 22 Aug 2013 15:23:46 +0100 Subject: Restore the download for hidden requests This was disabled for hidden requests as the download was by redirect, allowing people who have not been authenticated to conceivably access the download. We'll be moving to send_file instead, so can restore it. --- spec/integration/download_request_spec.rb | 55 ++++++++++++++++++++++++++++++- 1 file changed, 54 insertions(+), 1 deletion(-) (limited to 'spec/integration/download_request_spec.rb') diff --git a/spec/integration/download_request_spec.rb b/spec/integration/download_request_spec.rb index 8af1c9ff1..dd492e42a 100644 --- a/spec/integration/download_request_spec.rb +++ b/spec/integration/download_request_spec.rb @@ -56,7 +56,60 @@ describe 'when making a zipfile available' do end end + context 'when a request is "requester_only"' do + + before do + @non_owner = login(FactoryGirl.create(:user)) + @info_request = FactoryGirl.create(:info_request_with_incoming, + :prominence => 'requester_only') + @request_owner = login(@info_request.user) + @admin = login(FactoryGirl.create(:admin_user)) + end + + + it 'should allow a download of the request by the request owner and admin only' do + # Requester can access the zip + inspect_zip_download(@request_owner, @info_request) do |zip| + zip.count.should == 1 + zip.read('correspondence.txt').should match('hereisthetext') + end + # Non-owner can't + @non_owner.get_via_redirect "request/#{@info_request.url_title}/download" + @non_owner.response.code.should == '410' + # Admin can + inspect_zip_download(@admin, @info_request) do |zip| + zip.count.should == 1 + zip.read('correspondence.txt').should match('hereisthetext') + end + end + end + + context 'when a request is made "hidden"' do + + it 'should not allow a download of the request by an admin only' do + @non_owner = login(FactoryGirl.create(:user)) + @info_request = FactoryGirl.create(:info_request_with_incoming, + :prominence => 'hidden') + @request_owner = login(@info_request.user) + @admin = login(FactoryGirl.create(:admin_user)) + + # Requester can't access the zip + @request_owner.get_via_redirect "request/#{@info_request.url_title}/download" + @request_owner.response.code.should == '410' + # Non-owner can't + @non_owner.get_via_redirect "request/#{@info_request.url_title}/download" + @non_owner.response.code.should == '410' + # Admin can + inspect_zip_download(@admin, @info_request) do |zip| + zip.count.should == 1 + zip.read('correspondence.txt').should match('hereisthetext') + end + end + + end + context 'when an incoming message is made "requester_only"' do + it 'should not include the incoming message or attachments in a download of the entire request by a non-request owner' do @@ -90,7 +143,7 @@ describe 'when making a zipfile available' do end - it 'should successfully make a zipfile for an external request', :focus => true do + it 'should successfully make a zipfile for an external request' do external_request = FactoryGirl.create(:external_request) user = login(FactoryGirl.create(:user)) inspect_zip_download(user, external_request){ |zip| zip.count.should == 1 } -- cgit v1.2.3 From c3d4859b0d02f772944042c2758b4c924871499f Mon Sep 17 00:00:00 2001 From: Louise Crow Date: Thu, 22 Aug 2013 16:17:31 +0100 Subject: Add expectations for admin and requester. --- spec/integration/download_request_spec.rb | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) (limited to 'spec/integration/download_request_spec.rb') diff --git a/spec/integration/download_request_spec.rb b/spec/integration/download_request_spec.rb index dd492e42a..18873299c 100644 --- a/spec/integration/download_request_spec.rb +++ b/spec/integration/download_request_spec.rb @@ -84,7 +84,7 @@ describe 'when making a zipfile available' do end end - context 'when a request is made "hidden"' do + context 'when a request is "hidden"' do it 'should not allow a download of the request by an admin only' do @non_owner = login(FactoryGirl.create(:user)) @@ -111,11 +111,12 @@ describe 'when making a zipfile available' do context 'when an incoming message is made "requester_only"' do it 'should not include the incoming message or attachments in a download of the entire request - by a non-request owner' do + by a non-request owner but should retain them for owner and admin' do # Non-owner can download zip with incoming and attachments non_owner = login(FactoryGirl.create(:user)) info_request = FactoryGirl.create(:info_request_with_incoming_attachments) + inspect_zip_download(non_owner, info_request) do |zip| zip.count.should == 3 zip.read('correspondence.txt').should match('hereisthetext') @@ -128,6 +129,13 @@ describe 'when making a zipfile available' do admin.post_via_redirect "/en/admin/incoming/update/#{info_request.incoming_messages.first.id}", post_data admin.response.should be_success + # Admin retains the requester only things + inspect_zip_download(admin, info_request) do |zip| + zip.count.should == 3 + zip.read('correspondence.txt').should match('hereisthetext') + end + + # Zip for non owner is now without requester_only things inspect_zip_download(non_owner, info_request) do |zip| zip.count.should == 1 correspondence_text = zip.read('correspondence.txt') @@ -136,10 +144,14 @@ describe 'when making a zipfile available' do correspondence_text.should match(expected_text) end - end + # Requester retains the requester only things + owner = login(info_request.user) + inspect_zip_download(owner, info_request) do |zip| + zip.count.should == 3 + zip.read('correspondence.txt').should match('hereisthetext') + end - it 'should include the incoming message and attachments in a download of the entire request - by the owner' + end end -- cgit v1.2.3 From 97c86348f29a4050e8a1d96afa1edad75852a7f4 Mon Sep 17 00:00:00 2001 From: Louise Crow Date: Thu, 22 Aug 2013 16:27:28 +0100 Subject: Clean up the test download dir after use. --- spec/integration/download_request_spec.rb | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'spec/integration/download_request_spec.rb') diff --git a/spec/integration/download_request_spec.rb b/spec/integration/download_request_spec.rb index 18873299c..01e618f3c 100644 --- a/spec/integration/download_request_spec.rb +++ b/spec/integration/download_request_spec.rb @@ -3,6 +3,10 @@ require File.expand_path(File.dirname(__FILE__) + '/alaveteli_dsl') describe 'when making a zipfile available' do + after do + FileUtils.rm_rf(InfoRequest.download_zip_dir) + end + def inspect_zip_download(session, info_request) session.get_via_redirect "request/#{info_request.url_title}/download" session.response.should be_success -- cgit v1.2.3 From 3fb6acc3b7cc58a8d4260227e29c8dd4cfbca76a Mon Sep 17 00:00:00 2001 From: Louise Crow Date: Thu, 22 Aug 2013 17:08:27 +0100 Subject: Add a test of incoming message hiding with PDF conversion --- spec/integration/download_request_spec.rb | 59 +++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) (limited to 'spec/integration/download_request_spec.rb') diff --git a/spec/integration/download_request_spec.rb b/spec/integration/download_request_spec.rb index 01e618f3c..93475fff2 100644 --- a/spec/integration/download_request_spec.rb +++ b/spec/integration/download_request_spec.rb @@ -28,6 +28,65 @@ describe 'when making a zipfile available' do receive_incoming_mail(name, info_request.incoming_email) end + context 'when an html to pdf converter is supplied' do + + before do + # We want to test the contents of the pdf, and we don't know whether a particular + # instance will have a working html_to_pdf tool, so just copy the HTML rendered + # to the PDF file for the purposes of checking it doesn't contain anything that + # shouldn't be there. + AlaveteliConfiguration.stub!(:html_to_pdf_command).and_return('/bin/cp') + end + + context 'when an incoming message is made "requester_only"' do + + it 'should not include the incoming message or attachments in a download of the entire request + by a non-request owner but should retain them for owner and admin' do + + # Non-owner can download zip with incoming and attachments + non_owner = login(FactoryGirl.create(:user)) + info_request = FactoryGirl.create(:info_request_with_incoming_attachments) + + inspect_zip_download(non_owner, info_request) do |zip| + zip.count.should == 3 + zip.read('correspondence.pdf').should match('hereisthetext') + end + + # Admin makes the incoming message requester only + admin = login(FactoryGirl.create(:admin_user)) + post_data = {:incoming_message => {:prominence => 'requester_only', + :prominence_reason => 'boring'}} + admin.post_via_redirect "/en/admin/incoming/update/#{info_request.incoming_messages.first.id}", post_data + admin.response.should be_success + + # Admin retains the requester only things + inspect_zip_download(admin, info_request) do |zip| + zip.count.should == 3 + zip.read('correspondence.pdf').should match('hereisthetext') + end + + # Zip for non owner is now without requester_only things + inspect_zip_download(non_owner, info_request) do |zip| + zip.count.should == 1 + correspondence_text = zip.read('correspondence.pdf') + correspondence_text.should_not match('hereisthetext') + expected_text = "This message has been hidden.\n boring" + correspondence_text.should match(expected_text) + end + + # Requester retains the requester only things + owner = login(info_request.user) + inspect_zip_download(owner, info_request) do |zip| + zip.count.should == 3 + zip.read('correspondence.pdf').should match('hereisthetext') + end + + end + + end + + end + context 'when no html to pdf converter is supplied' do before do -- cgit v1.2.3 From d9c88eba4fe22688ef4f1503caa2deb74b1dc9e5 Mon Sep 17 00:00:00 2001 From: Louise Crow Date: Tue, 27 Aug 2013 14:31:56 +0100 Subject: Hide hidden outgoing messages in download. --- spec/integration/download_request_spec.rb | 98 ++++++++++++++++++++++++++++++- 1 file changed, 97 insertions(+), 1 deletion(-) (limited to 'spec/integration/download_request_spec.rb') diff --git a/spec/integration/download_request_spec.rb b/spec/integration/download_request_spec.rb index 93475fff2..a4e346e47 100644 --- a/spec/integration/download_request_spec.rb +++ b/spec/integration/download_request_spec.rb @@ -85,6 +85,54 @@ describe 'when making a zipfile available' do end + context 'when an outgoing message is made "requester_only"' do + + it 'should not include the outgoing message in a download of the entire request + by a non-request owner but should retain them for owner and admin' do + + # Non-owner can download zip with outgoing + non_owner = login(FactoryGirl.create(:user)) + info_request = FactoryGirl.create(:info_request) + + inspect_zip_download(non_owner, info_request) do |zip| + zip.count.should == 1 + zip.read('correspondence.pdf').should match('Some information please') + end + + # Admin makes the incoming message requester only + admin = login(FactoryGirl.create(:admin_user)) + post_data = {:outgoing_message => {:prominence => 'requester_only', + :prominence_reason => 'boring', + :body => 'Some information please'}} + admin.post_via_redirect "/en/admin/outgoing/update/#{info_request.outgoing_messages.first.id}", post_data + admin.response.should be_success + + # Admin retains the requester only things + inspect_zip_download(admin, info_request) do |zip| + zip.count.should == 1 + zip.read('correspondence.pdf').should match('Some information please') + end + + # Zip for non owner is now without requester_only things + inspect_zip_download(non_owner, info_request) do |zip| + zip.count.should == 1 + correspondence_text = zip.read('correspondence.pdf') + correspondence_text.should_not match('Some information please') + expected_text = "This message has been hidden.\n boring" + correspondence_text.should match(expected_text) + end + + # Requester retains the requester only things + owner = login(info_request.user) + inspect_zip_download(owner, info_request) do |zip| + zip.count.should == 1 + zip.read('correspondence.pdf').should match('Some information please') + end + + end + + end + end context 'when no html to pdf converter is supplied' do @@ -176,7 +224,7 @@ describe 'when making a zipfile available' do it 'should not include the incoming message or attachments in a download of the entire request by a non-request owner but should retain them for owner and admin' do - # Non-owner can download zip with incoming and attachments + # Non-owner can download zip with outgoing non_owner = login(FactoryGirl.create(:user)) info_request = FactoryGirl.create(:info_request_with_incoming_attachments) @@ -218,6 +266,54 @@ describe 'when making a zipfile available' do end + context 'when an outgoing message is made "requester_only"' do + + it 'should not include the outgoing message in a download of the entire request + by a non-request owner but should retain them for owner and admin' do + + # Non-owner can download zip with incoming and attachments + non_owner = login(FactoryGirl.create(:user)) + info_request = FactoryGirl.create(:info_request) + + inspect_zip_download(non_owner, info_request) do |zip| + zip.count.should == 1 + zip.read('correspondence.txt').should match('Some information please') + end + + # Admin makes the incoming message requester only + admin = login(FactoryGirl.create(:admin_user)) + post_data = {:outgoing_message => {:prominence => 'requester_only', + :prominence_reason => 'boring', + :body => 'Some information please'}} + admin.post_via_redirect "/en/admin/outgoing/update/#{info_request.outgoing_messages.first.id}", post_data + admin.response.should be_success + + # Admin retains the requester only things + inspect_zip_download(admin, info_request) do |zip| + zip.count.should == 1 + zip.read('correspondence.txt').should match('Some information please') + end + + # Zip for non owner is now without requester_only things + inspect_zip_download(non_owner, info_request) do |zip| + zip.count.should == 1 + correspondence_text = zip.read('correspondence.txt') + correspondence_text.should_not match('Some information please') + expected_text = 'This message has been hidden. boring' + correspondence_text.should match(expected_text) + end + + # Requester retains the requester only things + owner = login(info_request.user) + inspect_zip_download(owner, info_request) do |zip| + zip.count.should == 1 + zip.read('correspondence.txt').should match('Some information please') + end + + end + + end + it 'should successfully make a zipfile for an external request' do external_request = FactoryGirl.create(:external_request) user = login(FactoryGirl.create(:user)) -- cgit v1.2.3 From 257c62c69d43549c4e4ae56d32598f3b10733931 Mon Sep 17 00:00:00 2001 From: Louise Crow Date: Wed, 28 Aug 2013 10:50:47 +0100 Subject: Make test ruby 1.8.7 compatible. --- spec/integration/download_request_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'spec/integration/download_request_spec.rb') diff --git a/spec/integration/download_request_spec.rb b/spec/integration/download_request_spec.rb index a4e346e47..84dda9a1b 100644 --- a/spec/integration/download_request_spec.rb +++ b/spec/integration/download_request_spec.rb @@ -14,7 +14,7 @@ describe 'when making a zipfile available' do f.binmode f.write(session.response.body) f.flush - Zip::ZipFile::open(f) do |zip| + Zip::ZipFile::open(f.path) do |zip| yield zip end end -- cgit v1.2.3 From 661a103922279f05ad5027d0dfabc8a0ff649e92 Mon Sep 17 00:00:00 2001 From: Louise Crow Date: Wed, 28 Aug 2013 12:54:48 +0100 Subject: Add message index to attachment files So that files attached to different messages with the same name and url_part don't get overwritten. --- spec/integration/download_request_spec.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'spec/integration/download_request_spec.rb') 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 -- cgit v1.2.3 From a176da3b7611153421fc6a33bb502297ae50a0e2 Mon Sep 17 00:00:00 2001 From: Louise Crow Date: Mon, 16 Sep 2013 12:55:39 +0100 Subject: Use 403, not 410, for hidden items. As @mhl points out, this more clearly indicates that they may come back at some point. --- spec/integration/download_request_spec.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'spec/integration/download_request_spec.rb') diff --git a/spec/integration/download_request_spec.rb b/spec/integration/download_request_spec.rb index 2af98c271..638198cde 100644 --- a/spec/integration/download_request_spec.rb +++ b/spec/integration/download_request_spec.rb @@ -186,7 +186,7 @@ describe 'when making a zipfile available' do end # Non-owner can't @non_owner.get_via_redirect "request/#{@info_request.url_title}/download" - @non_owner.response.code.should == '410' + @non_owner.response.code.should == '403' # Admin can inspect_zip_download(@admin, @info_request) do |zip| zip.count.should == 1 @@ -206,10 +206,10 @@ describe 'when making a zipfile available' do # Requester can't access the zip @request_owner.get_via_redirect "request/#{@info_request.url_title}/download" - @request_owner.response.code.should == '410' + @request_owner.response.code.should == '403' # Non-owner can't @non_owner.get_via_redirect "request/#{@info_request.url_title}/download" - @non_owner.response.code.should == '410' + @non_owner.response.code.should == '403' # Admin can inspect_zip_download(@admin, @info_request) do |zip| zip.count.should == 1 -- cgit v1.2.3