aboutsummaryrefslogtreecommitdiffstats
path: root/spec/integration/download_request_spec.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/integration/download_request_spec.rb')
-rw-r--r--spec/integration/download_request_spec.rb98
1 files changed, 97 insertions, 1 deletions
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))