aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthew Landauer <matthew@openaustralia.org>2013-02-12 14:11:06 +1100
committerMatthew Landauer <matthew@openaustralia.org>2013-02-12 14:11:06 +1100
commitaeef1a20034b0ffb57f10d3bf2d5ed291bcf789c (patch)
tree17c63134882cf9e34799bc0562fa4935dc483cdf
parent2eadcc3417b11237f9e40dd5eb5804b2fcc44c82 (diff)
Retain filter settings when redirecting a public body to its canonical url
-rw-r--r--app/controllers/public_body_controller.rb2
-rw-r--r--spec/controllers/public_body_controller_spec.rb5
2 files changed, 6 insertions, 1 deletions
diff --git a/app/controllers/public_body_controller.rb b/app/controllers/public_body_controller.rb
index d88ab66e3..49502cc2c 100644
--- a/app/controllers/public_body_controller.rb
+++ b/app/controllers/public_body_controller.rb
@@ -25,7 +25,7 @@ class PublicBodyController < ApplicationController
end
# If found by historic name, or alternate locale name, redirect to new name
if @public_body.url_name != params[:url_name]
- redirect_to show_public_body_url(:url_name => @public_body.url_name)
+ redirect_to :url_name => @public_body.url_name
return
end
diff --git a/spec/controllers/public_body_controller_spec.rb b/spec/controllers/public_body_controller_spec.rb
index 29ece18cb..5f4012737 100644
--- a/spec/controllers/public_body_controller_spec.rb
+++ b/spec/controllers/public_body_controller_spec.rb
@@ -67,6 +67,11 @@ describe PublicBodyController, "when showing a body" do
ActionController::Routing::Routes.filters = old_filters
end
+ it "should remember the filter (view) setting on redirecting" do
+ get :show, :show_locale => "es", :url_name => "tgq", :view => 'successful'
+ response.should redirect_to show_public_body_successful_url(:url_name => "etgq")
+ end
+
it "should redirect to newest name if you use historic name of public body in URL" do
get :show, :url_name => "hdink", :view => 'all'
response.should redirect_to(:controller => 'public_body', :action => 'show', :url_name => "dfh")