diff options
-rw-r--r-- | app/controllers/request_controller.rb | 4 | ||||
-rw-r--r-- | app/models/track_thing.rb | 4 | ||||
-rw-r--r-- | app/views/general/search.rhtml | 52 | ||||
-rw-r--r-- | spec/controllers/general_controller_spec.rb | 34 | ||||
-rw-r--r-- | spec/controllers/request_controller_spec.rb | 7 |
5 files changed, 48 insertions, 53 deletions
diff --git a/app/controllers/request_controller.rb b/app/controllers/request_controller.rb index 58ea944cb..7ac979453 100644 --- a/app/controllers/request_controller.rb +++ b/app/controllers/request_controller.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: request_controller.rb,v 1.84 2008-05-15 17:40:43 francis Exp $ +# $Id: request_controller.rb,v 1.85 2008-05-15 22:18:19 francis Exp $ class RequestController < ApplicationController @@ -60,7 +60,7 @@ class RequestController < ApplicationController else raise "unknown request list view " + @view.to_s end - @xapian_object = perform_search([InfoRequestEvent], sortby, 'request_collapse') + @xapian_object = perform_search([InfoRequestEvent], query, sortby, 'request_collapse') end # Page new form posts to diff --git a/app/models/track_thing.rb b/app/models/track_thing.rb index 53e5817b0..86349d761 100644 --- a/app/models/track_thing.rb +++ b/app/models/track_thing.rb @@ -21,7 +21,7 @@ # Copyright (c) 2008 UK Citizens Online Democracy. All rights reserved. # Email: francis@mysociety.org; WWW: http://www.mysociety.org/ # -# $Id: track_thing.rb,v 1.17 2008-05-12 10:57:44 francis Exp $ +# $Id: track_thing.rb,v 1.18 2008-05-15 22:18:19 francis Exp $ class TrackThing < ActiveRecord::Base belongs_to :tracking_user, :class_name => 'User' @@ -127,7 +127,7 @@ class TrackThing < ActiveRecord::Base @params = { # Website :set_title => "How would you like to be told when any request succeeds?", - :list_description => "any <a href=\"/list\">successful requests</a>", + :list_description => "any <a href=\"/list/successful\">successful requests</a>", :verb_on_page => "Be told when any request succeeds", :verb_on_page_already => "being told when any request succeeds", # Email diff --git a/app/views/general/search.rhtml b/app/views/general/search.rhtml index a31596463..839fe0155 100644 --- a/app/views/general/search.rhtml +++ b/app/views/general/search.rhtml @@ -20,46 +20,50 @@ </p> <% end %> -<%=link_to_unless @sortby.nil?, "Show most relevant results first", search_url(@query, nil) %> -| -<%=link_to_unless @sortby == 'newest', "Newest results first", search_url(@query, 'newest') %> +<% if not @query.nil? %> + <%=link_to_unless @sortby.nil?, "Show most relevant results first", search_url(@query, nil) %> + | + <%=link_to_unless @sortby == 'newest', "Newest results first", search_url(@query, 'newest') %> +<% end %> <% if @total_hits == 0 %> <h1><%=@title %></h1> <% end %> -<% if @spelling_correction %> - <p id="did_you_mean">Did you mean: <%= link_to @spelling_correction, search_url(@spelling_correction, @sortby) %></p> -<% end %> +<% if not @query.nil? %> + <% if @spelling_correction %> + <p id="did_you_mean">Did you mean: <%= link_to @spelling_correction, search_url(@spelling_correction, @sortby) %></p> + <% end %> + + <% if @xapian_bodies.results.size > 0 %> + <h1><%= "Public authorities " + ((@page-1)*@per_page+1).to_s + "-" + [@page*@per_page, @xapian_bodies.matches_estimated].min.to_s + " of " + @xapian_bodies.matches_estimated.to_s + " for '" + h(@query) + "'" %></h1> -<% if @xapian_bodies.results.size > 0 %> - <h1><%= "Public authorities " + ((@page-1)*@per_page+1).to_s + "-" + [@page*@per_page, @xapian_bodies.matches_estimated].min.to_s + " of " + @xapian_bodies.matches_estimated.to_s + " for '" + h(@query) + "'" %></h1> + <% for result in @xapian_bodies.results %> + <%= render :partial => 'body/body_listing_single', :locals => { :public_body => result[:model] } %> + <% end %> - <% for result in @xapian_bodies.results %> - <%= render :partial => 'body/body_listing_single', :locals => { :public_body => result[:model] } %> + <%= will_paginate WillPaginate::Collection.new(@page, @per_page, @xapian_bodies.matches_estimated) %> <% end %> - <%= will_paginate WillPaginate::Collection.new(@page, @per_page, @xapian_bodies.matches_estimated) %> -<% end %> + <% if @xapian_users.results.size > 0 %> + <h1><%= "People " + ((@page-1)*@per_page+1).to_s + "-" + [@page*@per_page, @xapian_users.matches_estimated].min.to_s + " of " + @xapian_users.matches_estimated.to_s + " for '" + h(@query) + "'" %></h1> -<% if @xapian_users.results.size > 0 %> - <h1><%= "People " + ((@page-1)*@per_page+1).to_s + "-" + [@page*@per_page, @xapian_users.matches_estimated].min.to_s + " of " + @xapian_users.matches_estimated.to_s + " for '" + h(@query) + "'" %></h1> + <% for result in @xapian_users.results %> + <%= render :partial => 'user/user_listing_single', :locals => { :display_user => result[:model] } %> + <% end %> - <% for result in @xapian_users.results %> - <%= render :partial => 'user/user_listing_single', :locals => { :display_user => result[:model] } %> + <%= will_paginate WillPaginate::Collection.new(@page, @per_page, @xapian_users.matches_estimated) %> <% end %> - <%= will_paginate WillPaginate::Collection.new(@page, @per_page, @xapian_users.matches_estimated) %> -<% end %> + <% if @xapian_requests.results.size > 0 %> + <h1><%= "FOI requests " + ((@page-1)*@per_page+1).to_s + "-" + [@page*@per_page, @xapian_requests.matches_estimated].min.to_s + " of " + @xapian_requests.matches_estimated.to_s + " for '" + h(@query) + "'" %></h1> -<% if @xapian_requests.results.size > 0 %> - <h1><%= "FOI requests " + ((@page-1)*@per_page+1).to_s + "-" + [@page*@per_page, @xapian_requests.matches_estimated].min.to_s + " of " + @xapian_requests.matches_estimated.to_s + " for '" + h(@query) + "'" %></h1> + <% for result in @xapian_requests.results %> + <%= render :partial => 'request/request_listing_via_event', :locals => { :event => result[:model], :info_request => result[:model].info_request } %> + <% end %> - <% for result in @xapian_requests.results %> - <%= render :partial => 'request/request_listing_via_event', :locals => { :event => result[:model], :info_request => result[:model].info_request } %> + <%= will_paginate WillPaginate::Collection.new(@page, @per_page, @xapian_requests.matches_estimated) %> <% end %> - - <%= will_paginate WillPaginate::Collection.new(@page, @per_page, @xapian_requests.matches_estimated) %> <% end %> <% if @show_tips %> diff --git a/spec/controllers/general_controller_spec.rb b/spec/controllers/general_controller_spec.rb index 276b46aac..abc63c290 100644 --- a/spec/controllers/general_controller_spec.rb +++ b/spec/controllers/general_controller_spec.rb @@ -42,41 +42,31 @@ describe GeneralController, "when searching" do get :search, :combined => ['"fancy dog"'] response.should render_template('search') - assigns[:search_hits].should == 1 - assigns[:search_results].size.should == 1 - assigns[:search_results][0][:model].should == info_request_events(:useless_outgoing_message_event) + assigns[:xapian_requests].matches_estimated.should == 1 + assigns[:xapian_requests].results.size.should == 1 + assigns[:xapian_requests].results[0][:model].should == info_request_events(:useless_outgoing_message_event) - assigns[:highlight_words].should == ["fancy", "dog"] + assigns[:xapian_requests].words_to_highlight == ["fancy", "dog"] end it "should show help when searching for nothing" do get :search_redirect, :query => nil response.should render_template('search') - assigns[:search_hits].should be_nil + assigns[:total_hits].should be_nil assigns[:query].should be_nil end - it "should find public body and incoming message (in that order) when searching for 'geraldine quango'" do + it "should find public body and incoming message when searching for 'geraldine quango'" do get :search, :combined => ['geraldine quango'] response.should render_template('search') - assigns[:search_hits].should == 2 - assigns[:search_results].size.should == 2 - assigns[:search_results][0][:model].should == public_bodies(:geraldine_public_body) - assigns[:search_results][1][:model].should == info_request_events(:useless_incoming_message_event) - end - - it "should find incoming message and public body (in that order) when searching for 'geraldine quango', newest first" do - get :search, :combined => ['geraldine quango','newest'] - response.should render_template('search') + assigns[:xapian_requests].matches_estimated.should == 1 + assigns[:xapian_requests].results.size.should == 1 + assigns[:xapian_requests].results[0][:model].should == info_request_events(:useless_incoming_message_event) - assigns[:search_hits].should == 2 - assigns[:search_results].size.should == 2 - assigns[:search_results][0][:model].should == info_request_events(:useless_incoming_message_event) - assigns[:search_results][1][:model].should == public_bodies(:geraldine_public_body) + assigns[:xapian_bodies].matches_estimated.should == 1 + assigns[:xapian_bodies].results.size.should == 1 + assigns[:xapian_bodies].results[0][:model].should == public_bodies(:geraldine_public_body) end - - - # assigns[:display_user].should == users(:bob_smith_user) end diff --git a/spec/controllers/request_controller_spec.rb b/spec/controllers/request_controller_spec.rb index 980094e7a..411b2948b 100644 --- a/spec/controllers/request_controller_spec.rb +++ b/spec/controllers/request_controller_spec.rb @@ -21,9 +21,10 @@ describe RequestController, "when listing all requests" do get :list # reverse-chronological order - assigns[:search_results].size.should == 2 - assigns[:search_results][0][:model].should == info_request_events(:silly_outgoing_message_event) - assigns[:search_results][1][:model].should == info_request_events(:useless_outgoing_message_event) + assigns[:xapian_object].matches_estimated.should == 2 + assigns[:xapian_object].results.size.should == 2 + assigns[:xapian_object].results[0][:model].should == info_request_events(:silly_outgoing_message_event) + assigns[:xapian_object].results[1][:model].should == info_request_events(:useless_outgoing_message_event) end end |