aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--app/controllers/request_controller.rb14
-rw-r--r--spec/controllers/request_controller_spec.rb6
2 files changed, 16 insertions, 4 deletions
diff --git a/app/controllers/request_controller.rb b/app/controllers/request_controller.rb
index 9e2c291dc..9f17532b8 100644
--- a/app/controllers/request_controller.rb
+++ b/app/controllers/request_controller.rb
@@ -900,10 +900,16 @@ class RequestController < ApplicationController
# Type ahead search
def search_typeahead
- # Since acts_as_xapian doesn't support the Partial match flag, we work around it
- # by making the last work a wildcard, which is quite the same
- query = params[:q]
- @xapian_requests = perform_search_typeahead(query, InfoRequestEvent)
+ # Since acts_as_xapian doesn't support the Partial match flag, we work
+ # around it by making the last word a wildcard, which is quite the same
+ @query = ''
+
+ if params.key?(:requested_from)
+ @query << "requested_from:#{ params[:requested_from] } "
+ end
+
+ @query << params[:q]
+ @xapian_requests = perform_search_typeahead(@query, InfoRequestEvent)
render :partial => "request/search_ahead"
end
diff --git a/spec/controllers/request_controller_spec.rb b/spec/controllers/request_controller_spec.rb
index 6c0f4573e..ce91f7a83 100644
--- a/spec/controllers/request_controller_spec.rb
+++ b/spec/controllers/request_controller_spec.rb
@@ -2380,6 +2380,12 @@ describe RequestController, "when doing type ahead searches" do
get :search_typeahead, :q => "dog -chicken"
assigns[:xapian_requests].results.size.should == 1
end
+
+ it 'can filter search results by public body' do
+ get :search_typeahead, :q => 'boring', :requested_from => 'dfh'
+ expect(assigns[:query]).to eq('requested_from:dfh boring')
+ end
+
end
describe RequestController, "when showing similar requests" do