aboutsummaryrefslogtreecommitdiffstats
path: root/spec/controllers
diff options
context:
space:
mode:
Diffstat (limited to 'spec/controllers')
-rw-r--r--spec/controllers/public_body_controller_spec.rb2
-rw-r--r--spec/controllers/request_controller_spec.rb35
-rw-r--r--spec/controllers/track_controller_spec.rb2
-rw-r--r--spec/controllers/user_controller_spec.rb2
4 files changed, 32 insertions, 9 deletions
diff --git a/spec/controllers/public_body_controller_spec.rb b/spec/controllers/public_body_controller_spec.rb
index e6eca0781..9eca43aee 100644
--- a/spec/controllers/public_body_controller_spec.rb
+++ b/spec/controllers/public_body_controller_spec.rb
@@ -1,7 +1,5 @@
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
-require 'json'
-
describe PublicBodyController, "when showing a body" do
integrate_views
diff --git a/spec/controllers/request_controller_spec.rb b/spec/controllers/request_controller_spec.rb
index 9add32f1e..f50158ff9 100644
--- a/spec/controllers/request_controller_spec.rb
+++ b/spec/controllers/request_controller_spec.rb
@@ -1,8 +1,6 @@
# -*- coding: utf-8 -*-
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
-require 'json'
-
describe RequestController, "when listing recent requests" do
before(:each) do
@@ -222,7 +220,6 @@ describe RequestController, "when showing one request" do
get :get_attachment, :incoming_message_id => ir.incoming_messages[1].id, :id => ir.id, :part => 2, :file_name => ['hello.txt'], :skip_cache => 1
response.content_type.should == "text/plain"
response.should have_text(/Second hello/)
-
get :get_attachment, :incoming_message_id => ir.incoming_messages[1].id, :id => ir.id, :part => 3, :file_name => ['hello.txt'], :skip_cache => 1
response.content_type.should == "text/plain"
response.should have_text(/First hello/)
@@ -351,6 +348,15 @@ describe RequestController, "when showing one request" do
response.should have_text(/an unusual sort of file/)
end
+ it "should apply a content-disposition header" do
+ ir = info_requests(:fancy_dog_request)
+ receive_incoming_mail('incoming-request-attachment-unknown-extension.email', ir.incoming_email)
+ ir.reload
+ get :get_attachment, :incoming_message_id => ir.incoming_messages[1].id, :id => ir.id, :part => 2, :file_name => ['hello.qwglhm'], :skip_cache => 1
+ response.headers.should include("Content-Disposition")
+ response.headers["Content-Disposition"].should include('hello.qwglhm')
+ end
+
it "should not download attachments with wrong file name" do
ir = info_requests(:fancy_dog_request)
receive_incoming_mail('incoming-request-two-same-name.email', ir.incoming_email)
@@ -1737,7 +1743,30 @@ describe RequestController, "when doing type ahead searches" do
get :search_typeahead, :q => "dog -chicken"
assigns[:xapian_requests].results.size.should == 1
end
+end
+
+describe RequestController, "when showing similar requests" do
+ integrate_views
+
+ it "should work" do
+ get :similar, :url_title => info_requests(:badger_request).url_title
+ response.should render_template("request/similar")
+ assigns[:info_request].should == info_requests(:badger_request)
+ end
+ it "should show similar requests" do
+ badger_request = info_requests(:badger_request)
+ get :similar, :url_title => badger_request.url_title
+
+ # Xapian seems to think *all* the requests are similar
+ assigns[:xapian_object].results.map{|x|x[:model].info_request}.should =~ InfoRequest.all.reject {|x| x == badger_request}
+ end
+
+ it "should 404 for non-existent paths" do
+ lambda {
+ get :similar, :url_title => "there_is_really_no_such_path_owNAFkHR"
+ }.should raise_error(ActiveRecord::RecordNotFound)
+ end
end
diff --git a/spec/controllers/track_controller_spec.rb b/spec/controllers/track_controller_spec.rb
index 0dc5db607..2ebf0109a 100644
--- a/spec/controllers/track_controller_spec.rb
+++ b/spec/controllers/track_controller_spec.rb
@@ -1,7 +1,5 @@
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
-require 'json'
-
describe TrackController, "when making a new track on a request" do
before do
@ir = mock_model(InfoRequest, :url_title => 'myrequest',
diff --git a/spec/controllers/user_controller_spec.rb b/spec/controllers/user_controller_spec.rb
index 40649b6e1..0d7b19e1e 100644
--- a/spec/controllers/user_controller_spec.rb
+++ b/spec/controllers/user_controller_spec.rb
@@ -1,8 +1,6 @@
# coding: utf-8
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
-require 'json'
-
# XXX Use route_for or params_from to check /c/ links better
# http://rspec.rubyforge.org/rspec-rails/1.1.12/classes/Spec/Rails/Example/ControllerExampleGroup.html