From ba07a044614a1648eaa176436346a3aed7f4ac74 Mon Sep 17 00:00:00 2001 From: Seb Bacon Date: Wed, 11 Jan 2012 11:53:40 +0000 Subject: Fix problem with typeahead searches containing " - " characters and similar. Closes #328 --- spec/controllers/request_controller_spec.rb | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) (limited to 'spec/controllers/request_controller_spec.rb') 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 -- cgit v1.2.3