diff options
-rw-r--r-- | app/controllers/general_controller.rb | 17 | ||||
-rw-r--r-- | app/views/general/_public_body_query.rhtml | 5 | ||||
-rw-r--r-- | app/views/general/frontpage.rhtml (renamed from app/views/general/new_frontpage.rhtml) | 0 | ||||
-rw-r--r-- | config/routes.rb | 4 | ||||
-rw-r--r-- | spec/controllers/general_controller_spec.rb | 11 |
5 files changed, 4 insertions, 33 deletions
diff --git a/app/controllers/general_controller.rb b/app/controllers/general_controller.rb index 3ef29f149..11a1a61d7 100644 --- a/app/controllers/general_controller.rb +++ b/app/controllers/general_controller.rb @@ -5,12 +5,12 @@ # Copyright (c) 2008 UK Citizens Online Democracy. All rights reserved. # Email: francis@mysociety.org; WWW: http://www.mysociety.org/ # -# $Id: general_controller.rb,v 1.41 2008-09-08 02:00:17 francis Exp $ +# $Id: general_controller.rb,v 1.42 2008-09-08 02:05:13 francis Exp $ class GeneralController < ApplicationController # New, improved front page! - def new_frontpage + def frontpage # This is too slow #@popular_bodies = PublicBody.find(:all, :select => "*, (select count(*) from info_requests where info_requests.public_body_id = public_bodies.id) as c", :order => "c desc", :limit => 32) @@ -100,18 +100,5 @@ class GeneralController < ApplicationController render :text => "awake\n" end - private - - # Used in front page search for public body - def public_body_query(query) - # XXX try using search now we have spell correction? - - criteria = '%' + query + '%' - @public_bodies = PublicBody.find(:all, - :conditions => ["lower(name) like lower(?) or lower(short_name) like lower(?)", criteria, criteria], - :order => 'name', :limit=>10) - return @public_bodies - end - end diff --git a/app/views/general/_public_body_query.rhtml b/app/views/general/_public_body_query.rhtml deleted file mode 100644 index 77efdfcc1..000000000 --- a/app/views/general/_public_body_query.rhtml +++ /dev/null @@ -1,5 +0,0 @@ -<ul> -<% for public_body in @public_bodies %> -<li><%=h public_body.name %></li> -<% end %> -</ul> diff --git a/app/views/general/new_frontpage.rhtml b/app/views/general/frontpage.rhtml index 34fed3ee5..34fed3ee5 100644 --- a/app/views/general/new_frontpage.rhtml +++ b/app/views/general/frontpage.rhtml diff --git a/config/routes.rb b/config/routes.rb index e5a258a79..98b117958 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -4,7 +4,7 @@ # Copyright (c) 2007 UK Citizens Online Democracy. All rights reserved. # Email: francis@mysociety.org; WWW: http://www.mysociety.org/ # -# $Id: routes.rb,v 1.72 2008-09-08 02:00:24 francis Exp $ +# $Id: routes.rb,v 1.73 2008-09-08 02:05:14 francis Exp $ ActionController::Routing::Routes.draw do |map| @@ -15,7 +15,7 @@ ActionController::Routing::Routes.draw do |map| # Keep in mind you can assign values other than :controller and :action map.with_options :controller => 'general' do |general| - general.new_frontpage '/', :action => 'new_frontpage' + general.frontpage '/', :action => 'frontpage' general.search_redirect '/search', :action => 'search_redirect' # XXX combined is the search query, and then if sorted a "/newest" at the end. diff --git a/spec/controllers/general_controller_spec.rb b/spec/controllers/general_controller_spec.rb index f0ab38f38..23b7ba1b1 100644 --- a/spec/controllers/general_controller_spec.rb +++ b/spec/controllers/general_controller_spec.rb @@ -22,17 +22,6 @@ describe GeneralController, "when searching" do response.should be_success end - it "when doing public body AJAX search should return list of matches" do - get :auto_complete_for_public_body_query, :public_body => { :query => "humpa" } - assigns[:public_bodies] = [ public_bodies(:humpadink_public_body) ] - response.should render_template('_public_body_query') - end - - it "when front page public body search has exact name match, should redirect to public body page" do - post :frontpage, :public_body => { :query => public_bodies(:geraldine_public_body).name } - response.should redirect_to(:controller => 'body', :action => 'show', :url_name => public_bodies(:geraldine_public_body).url_name) - end - it "should redirect from search query URL to pretty URL" do post :search_redirect, :query => "mouse" # query hidden in POST parameters response.should redirect_to(:action => 'search', :combined => "mouse") # URL /search/:query |