aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSeb Bacon <seb.bacon@gmail.com>2012-05-04 13:49:49 +0100
committerSeb Bacon <seb.bacon@gmail.com>2012-05-04 13:49:49 +0100
commit6819aa8c2a9e2fd1b78d434a2a4133e5781b28b5 (patch)
treea7347dc4788c7667b7d5286da37944224550497c
parentbe0c3416917645ab190fba3cb937ce6893a291e1 (diff)
Ensure we redirect to the URL-based version of a search, when specified as a query string, even when the variety of search is "all". Fixes #448
-rw-r--r--config/routes.rb1
-rw-r--r--spec/integration/search_request_spec.rb7
2 files changed, 8 insertions, 0 deletions
diff --git a/config/routes.rb b/config/routes.rb
index 747cc9b06..0ebd3dbc8 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -22,6 +22,7 @@ ActionController::Routing::Routes.draw do |map|
general.blog '/blog', :action => 'blog'
general.custom_css '/stylesheets/custom.css', :action => 'custom_css'
general.search_redirect '/search', :action => 'search_redirect'
+ general.search_redirect '/search/all', :action => 'search_redirect'
# XXX combined is the search query, and then if sorted a "/newest" at the end.
# Couldn't find a way to do this in routes which also picked up multiple other slashes
# and dots and other characters that can appear in search query. So we sort it all
diff --git a/spec/integration/search_request_spec.rb b/spec/integration/search_request_spec.rb
index b62f0a4c4..17a7b4aaa 100644
--- a/spec/integration/search_request_spec.rb
+++ b/spec/integration/search_request_spec.rb
@@ -12,6 +12,13 @@ describe "When searching" do
response.body.should include("&quot;mouse stilton&quot;")
end
+ it "should redirect requests with search in query string to URL-based page" do
+ url = '/search/all?query=bob'
+ request_via_redirect("post", url)
+ response.request.url.should_not include(url)
+ response.request.url.should include("/search/bob/all")
+ end
+
it "should correctly execute simple search" do
request_via_redirect("post", "/search",
:query => 'bob'