diff options
author | Henare Degan <henare.degan@gmail.com> | 2013-03-05 14:08:12 +1100 |
---|---|---|
committer | Henare Degan <henare.degan@gmail.com> | 2013-03-05 14:49:13 +1100 |
commit | 10a76a091bce366a30850b3f60354e5fe52abf5e (patch) | |
tree | 1a9837a55a0d7ea0b79d20d3940ff7c7f1c3ef4e | |
parent | b9119dc77a78c648bf80444ebf01d03f0d146294 (diff) |
Fix track searches by changing the way the routing works
-rw-r--r-- | app/controllers/track_controller.rb | 5 | ||||
-rw-r--r-- | config/routes.rb | 8 | ||||
-rw-r--r-- | spec/controllers/track_controller_spec.rb | 2 |
3 files changed, 7 insertions, 8 deletions
diff --git a/app/controllers/track_controller.rb b/app/controllers/track_controller.rb index 23d79b30c..2679cacc9 100644 --- a/app/controllers/track_controller.rb +++ b/app/controllers/track_controller.rb @@ -80,10 +80,7 @@ class TrackController < ApplicationController # Track a search term def track_search_query - # XXX should be better thing in rails routes than having to do this - # join just to get / and . to work in a query. - query_array = params[:query_array] - @query = query_array.join("/") + @query = params[:query_array] # XXX more hackery to make alternate formats still work with query_array if /^(.*)\.json$/.match(@query) diff --git a/config/routes.rb b/config/routes.rb index f629f9220..5c76cc96f 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -126,9 +126,11 @@ Alaveteli::Application.routes.draw do match '/:feed/list/:view' => 'track#track_list', :as => :track_list, :view => nil, :feed => /(track|feed)/ match '/:feed/body/:url_name' => 'track#track_public_body', :as => :track_public_body, :feed => /(track|feed)/ match '/:feed/user/:url_name' => 'track#track_user', :as => :track_user, :feed => /(track|feed)/ - # XXX must be better way of getting dots and slashes in search queries to work than this *query_array - # Also, the :format doesn't work. See hacky code in the controller that makes up for this. - match '/:feed/search/*query_array' => 'track#track_search_query', :as => :track_search, :feed => /(track|feed)/ + # XXX :format doesn't work. See hacky code in the controller that makes up for this. + match '/:feed/search/:query_array' => 'track#track_search_query', + :as => :track_search, + :feed => /(track|feed)/, + :constraints => { :query_array => /.*/ } match '/track/update/:track_id' => 'track#update', :as => :update match '/track/delete_all_type' => 'track#delete_all_type', :as => :delete_all_type diff --git a/spec/controllers/track_controller_spec.rb b/spec/controllers/track_controller_spec.rb index 63192c99e..8d9d7637b 100644 --- a/spec/controllers/track_controller_spec.rb +++ b/spec/controllers/track_controller_spec.rb @@ -49,7 +49,7 @@ describe TrackController, "when making a new track on a request" do it "should save a search track and redirect to the right place" do session[:user_id] = @user.id @track_thing.should_receive(:save!) - get :track_search_query, :query_array => ["bob variety:sent"], :feed => 'track' + get :track_search_query, :query_array => "bob variety:sent", :feed => 'track' response.should redirect_to(:controller => 'general', :action => 'search', :combined => ["bob", "requests"]) end |