diff options
author | David Cabo <david@calibea.com> | 2011-09-01 02:46:22 +0200 |
---|---|---|
committer | David Cabo <david@calibea.com> | 2011-09-01 02:46:22 +0200 |
commit | 6a7c9cdd3c5bf3db7701ef1353f04527e96c8cc3 (patch) | |
tree | 59cfc21e66fc3c44eb01991ef03f253dcaaf010d /spec/controllers/public_body_controller_spec.rb | |
parent | 1fb99a4df2514cb6aea37fcf1fd4790234d77c7e (diff) | |
parent | 88c26439d7d00cc5f0e1ddcb7b0a0036fa3f9c88 (diff) |
Merge branch 'asktheeu-new-design' into develop (update New Request workflow to match new wireframes)
Diffstat (limited to 'spec/controllers/public_body_controller_spec.rb')
-rw-r--r-- | spec/controllers/public_body_controller_spec.rb | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/spec/controllers/public_body_controller_spec.rb b/spec/controllers/public_body_controller_spec.rb index df3fc10dc..8e35b4a8d 100644 --- a/spec/controllers/public_body_controller_spec.rb +++ b/spec/controllers/public_body_controller_spec.rb @@ -156,6 +156,41 @@ describe PublicBodyController, "when showing JSON version for API" do end +describe PublicBodyController, "when doing type ahead searches" do + fixtures :info_requests, :info_request_events, :public_bodies, :public_body_translations, :users, :incoming_messages, :raw_emails, :outgoing_messages, :comments + it "should return nothing for the empty query string" do + get :search_typeahead, :q => "" + response.should render_template('public_body/_search_ahead') + assigns[:xapian_requests].results.size.should == 0 + end + + it "should return a body matching the given keyword, but not users with a matching description" do + get :search_typeahead, :q => "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" + 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 + assigns[:xapian_requests].results[1][:model].name.should == public_bodies(:geraldine_public_body).name + 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 + 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 return partial matches" do + get :search_typeahead, :q => "geral" # 'geral' for '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 +end |