aboutsummaryrefslogtreecommitdiffstats
path: root/spec/controllers
diff options
context:
space:
mode:
Diffstat (limited to 'spec/controllers')
-rw-r--r--spec/controllers/public_body_controller_spec.rb10
-rw-r--r--spec/controllers/request_controller_spec.rb18
-rw-r--r--spec/controllers/user_controller_spec.rb13
3 files changed, 35 insertions, 6 deletions
diff --git a/spec/controllers/public_body_controller_spec.rb b/spec/controllers/public_body_controller_spec.rb
index 8182e1331..3996bd520 100644
--- a/spec/controllers/public_body_controller_spec.rb
+++ b/spec/controllers/public_body_controller_spec.rb
@@ -175,20 +175,20 @@ describe PublicBodyController, "when doing type ahead searches" do
fixtures :public_bodies, :public_body_translations, :public_body_versions, :users, :info_requests, :raw_emails, :incoming_messages, :outgoing_messages, :comments, :info_request_events, :track_things
it "should return nothing for the empty query string" do
- get :search_typeahead, :q => ""
+ get :search_typeahead, :query => ""
response.should render_template('public_body/_search_ahead')
assigns[:xapian_requests].should be_nil
end
it "should return a body matching the given keyword, but not users with a matching description" do
- get :search_typeahead, :q => "Geraldine"
+ get :search_typeahead, :query => "Geraldine"
response.should render_template('public_body/_search_ahead')
assigns[:xapian_requests].results.size.should == 1
assigns[:xapian_requests].results[0][:model].name.should == public_bodies(:geraldine_public_body).name
end
it "should return all requests matching any of the given keywords" do
- get :search_typeahead, :q => "Geraldine Humpadinking"
+ get :search_typeahead, :query => "Geraldine Humpadinking"
response.should render_template('public_body/_search_ahead')
assigns[:xapian_requests].results.size.should == 2
assigns[:xapian_requests].results[0][:model].name.should == public_bodies(:humpadink_public_body).name
@@ -196,14 +196,14 @@ describe PublicBodyController, "when doing type ahead searches" do
end
it "should return requests matching the given keywords in any of their locales" do
- get :search_typeahead, :q => "baguette" # part of the spanish notes
+ get :search_typeahead, :query => "baguette" # part of the spanish notes
response.should render_template('public_body/_search_ahead')
assigns[:xapian_requests].results.size.should == 1
assigns[:xapian_requests].results[0][:model].name.should == public_bodies(:humpadink_public_body).name
end
it "should not return matches for short words" do
- get :search_typeahead, :q => "b"
+ get :search_typeahead, :query => "b"
response.should render_template('public_body/_search_ahead')
assigns[:xapian_requests].should be_nil
end
diff --git a/spec/controllers/request_controller_spec.rb b/spec/controllers/request_controller_spec.rb
index 2bf45e914..fc62edc14 100644
--- a/spec/controllers/request_controller_spec.rb
+++ b/spec/controllers/request_controller_spec.rb
@@ -1487,11 +1487,27 @@ describe RequestController, "when doing type ahead searches" do
assigns[:xapian_requests].results[1][:model].title.should == info_requests(:naughty_chicken_request).title
end
- it "should not return matches for short words" do
+ it "should not return matches for short words" do
get :search_typeahead, :q => "a"
response.should render_template('request/_search_ahead.rhtml')
assigns[:xapian_requests].should be_nil
end
+
+ it "should not give an error when user users unintended search operators" do
+ for phrase in ["Marketing/PR activities - Aldborough E-Act Free Schoo",
+ "Request for communications between DCMS/Ed Vaizey and ICO from Jan 1st 2011 - May ",
+ "Bellevue Road Ryde Isle of Wight PO33 2AR - what is the"]
+ lambda {
+ get :search_typeahead, :q => phrase
+ }.should_not raise_error(StandardError)
+ end
+ end
+
+ it "should return all requests matching any of the given keywords" do
+ get :search_typeahead, :q => "dog -chicken"
+ assigns[:xapian_requests].results.size.should == 1
+ end
+
end
diff --git a/spec/controllers/user_controller_spec.rb b/spec/controllers/user_controller_spec.rb
index c13d7c9fc..2560b48c7 100644
--- a/spec/controllers/user_controller_spec.rb
+++ b/spec/controllers/user_controller_spec.rb
@@ -109,6 +109,19 @@ describe UserController, "when signing in" do
response.should_not send_email
end
+ it "should not log you in if you use an invalid PostRedirect token, and shouldn't give 500 error either" do
+ ActionController::Routing::Routes.filters.clear
+ get :signin, :r => "/list"
+ response.should render_template('sign')
+ post_redirect = "something invalid"
+ lambda {
+ post :signin, { :user_signin => { :email => 'bob@localhost', :password => 'jonespassword' },
+ :token => post_redirect
+ }
+ }.should_not raise_error(NoMethodError)
+ response.should render_template('sign')
+ end
+
# No idea how to test this in the test framework :(
# it "should have set a long lived cookie if they picked remember me, session cookie if they didn't" do
# get :signin, :r => "/list"