aboutsummaryrefslogtreecommitdiffstats
path: root/spec/controllers
diff options
context:
space:
mode:
authorLouise Crow <louise.crow@gmail.com>2013-08-14 14:56:21 +0100
committerLouise Crow <louise.crow@gmail.com>2013-09-16 12:41:44 +0100
commita9363f6c3926d5a8cba8db79176c1b76bc4118e7 (patch)
tree65e15026bd3d1619fa775eeb71d4574106be534e /spec/controllers
parent5104b1323ee8901c46aa76893b160ab5c7972fbb (diff)
Rewrite download spec
Make it an integration spec so we don't need to touch the internals so much.
Diffstat (limited to 'spec/controllers')
-rw-r--r--spec/controllers/request_controller_spec.rb48
1 files changed, 3 insertions, 45 deletions
diff --git a/spec/controllers/request_controller_spec.rb b/spec/controllers/request_controller_spec.rb
index 7e26d0ada..8f8e3afa0 100644
--- a/spec/controllers/request_controller_spec.rb
+++ b/spec/controllers/request_controller_spec.rb
@@ -191,7 +191,6 @@ describe RequestController, "when showing one request" do
before(:each) do
load_raw_emails_data
- FileUtils.rm_rf File.join(File.dirname(__FILE__), "../../cache/zips")
end
it "should be successful" do
@@ -768,49 +767,7 @@ describe RequestController, "when showing one request" do
end
end
- describe 'when making a zipfile available' do
- it "should have a different zipfile URL when the request changes" do
- title = 'why_do_you_have_such_a_fancy_dog'
- ir = info_requests(:fancy_dog_request)
- session[:user_id] = ir.user.id # bob_smith_user
- get :download_entire_request, :url_title => title
- assigns[:url_path].should contain /#{title}.zip$/
- old_path = assigns[:url_path]
- response.location.should contain /#{assigns[:url_path]}$/
- zipfile = Zip::ZipFile.open(File.join(File.dirname(__FILE__), "../../cache/zips", old_path)) { |zipfile|
- zipfile.count.should == 1 # just the message
- }
- receive_incoming_mail('incoming-request-two-same-name.email', ir.incoming_email)
- get :download_entire_request, :url_title => title
- assigns[:url_path].should contain /#{title}.zip$/
- old_path = assigns[:url_path]
- response.location.should contain /#{assigns[:url_path]}$/
- zipfile = Zip::ZipFile.open(File.join(File.dirname(__FILE__), "../../cache/zips", old_path)) { |zipfile|
- zipfile.count.should == 3 # the message plus two "hello-world.txt" files
- }
-
- # 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('incoming-request-attachment-unknown-extension.email', ir.incoming_email)
- get :download_entire_request, :url_title => title
- assigns[:url_path].should contain /#{title}.zip$/
- assigns[:url_path].should_not == old_path
- response.location.should contain assigns[:url_path]
- zipfile = Zip::ZipFile.open(File.join(File.dirname(__FILE__), "../../cache/zips", assigns[:url_path])) { |zipfile|
- zipfile.count.should == 4 # the message, two hello-world.txt plus the unknown attachment
- }
- end
-
- it 'should successfully make a zipfile for an external request' do
- info_request = info_requests(:external_request)
- get :download_entire_request, { :url_title => info_request.url_title },
- { :user_id => users(:bob_smith_user) }
- response.location.should contain /#{assigns[:url_path]}$/
- end
- end
end
end
@@ -825,7 +782,7 @@ describe RequestController, "when handling prominence" do
context 'when the request is hidden' do
before(:each) do
- @info_request = FactoryGirl.create(:info_request_with_attachments,
+ @info_request = FactoryGirl.create(:info_request_with_incoming_attachments,
prominence: 'hidden')
end
@@ -879,7 +836,7 @@ describe RequestController, "when handling prominence" do
context 'when the request is requester_only' do
before(:each) do
- @info_request = FactoryGirl.create(:info_request_with_attachments, prominence: 'requester_only')
+ @info_request = FactoryGirl.create(:info_request_with_incoming_attachments, prominence: 'requester_only')
end
it "should not show request if you're not logged in" do
@@ -975,6 +932,7 @@ describe RequestController, "when handling prominence" do
:part => 2,
:file_name => 'interesting.pdf'
end
+
end
context 'when the incoming message has prominence requester_only' do