aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorfrancis <francis>2008-02-27 12:09:03 +0000
committerfrancis <francis>2008-02-27 12:09:03 +0000
commit9d1ccab02460083797e7b5680dbb40c6f2fc23cd (patch)
treea55bf9f2f9466e6cdd0c54022fbfb1f70287c4d9
parentabc70d713ddbd2e337a0f419a268b964bed66832 (diff)
Rename simple_short_name to url_name in routing
-rw-r--r--app/controllers/body_controller.rb12
-rw-r--r--app/helpers/link_to_helper.rb4
-rw-r--r--config/routes.rb4
-rw-r--r--spec/controllers/body_controller_spec.rb10
4 files changed, 15 insertions, 15 deletions
diff --git a/app/controllers/body_controller.rb b/app/controllers/body_controller.rb
index a557c0cfc..6ad713455 100644
--- a/app/controllers/body_controller.rb
+++ b/app/controllers/body_controller.rb
@@ -4,27 +4,27 @@
# Copyright (c) 2007 UK Citizens Online Democracy. All rights reserved.
# Email: francis@mysociety.org; WWW: http://www.mysociety.org/
#
-# $Id: body_controller.rb,v 1.5 2008-02-27 12:04:10 francis Exp $
+# $Id: body_controller.rb,v 1.6 2008-02-27 12:09:03 francis Exp $
class BodyController < ApplicationController
# XXX tidy this up with better error messages, and a more standard infrastructure for the redirect to canonical URL
def show
@public_bodies = PublicBody.find(:all,
- :conditions => [ "url_name = ?", params[:simple_short_name] ])
+ :conditions => [ "url_name = ?", params[:url_name] ])
if @public_bodies.size > 1
- raise "Two bodies with the same URL name: " . params[:simple_short_name]
+ raise "Two bodies with the same URL name: " . params[:url_name]
end
# If none found, then search the history of short names, and do a redirect
if @public_bodies.size == 0
@public_bodies = PublicBody.find(:all,
- :conditions => [ "id in (select public_body_id from public_body_versions where url_name = ?)", params[:simple_short_name] ])
+ :conditions => [ "id in (select public_body_id from public_body_versions where url_name = ?)", params[:url_name] ])
if @public_bodies.size > 1
- raise "Two bodies with the same historical URL name: " . params[:simple_short_name]
+ raise "Two bodies with the same historical URL name: " . params[:url_name]
end
if @public_bodies.size == 0
raise "None found" # XXX proper 404
end
- redirect_to show_public_body_url(:simple_short_name => @public_bodies[0].url_name)
+ redirect_to show_public_body_url(:url_name => @public_bodies[0].url_name)
end
@public_body = @public_bodies[0]
end
diff --git a/app/helpers/link_to_helper.rb b/app/helpers/link_to_helper.rb
index 9fb26a4f1..dbf569f20 100644
--- a/app/helpers/link_to_helper.rb
+++ b/app/helpers/link_to_helper.rb
@@ -5,7 +5,7 @@
# Copyright (c) 2007 UK Citizens Online Democracy. All rights reserved.
# Email: francis@mysociety.org; WWW: http://www.mysociety.org/
#
-# $Id: link_to_helper.rb,v 1.16 2008-02-27 12:04:10 francis Exp $
+# $Id: link_to_helper.rb,v 1.17 2008-02-27 12:09:03 francis Exp $
module LinkToHelper
@@ -27,7 +27,7 @@ module LinkToHelper
# Public bodies
def public_body_url(public_body)
- return show_public_body_url(:simple_short_name => public_body.url_name, :only_path => true)
+ return show_public_body_url(:url_name => public_body.url_name, :only_path => true)
end
def public_body_link_short(public_body)
link_to h(public_body.short_or_long_name), public_body_url(public_body)
diff --git a/config/routes.rb b/config/routes.rb
index 4de8c1a35..d60100f9d 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.37 2008-02-22 13:49:37 francis Exp $
+# $Id: routes.rb,v 1.38 2008-02-27 12:09:03 francis Exp $
ActionController::Routing::Routes.draw do |map|
# The priority is based upon order of creation: first created -> highest priority.
@@ -38,7 +38,7 @@ ActionController::Routing::Routes.draw do |map|
map.with_options :controller => 'body' do |body|
body.list_public_bodies "/body", :action => 'list'
- body.show_public_body "/body/:simple_short_name", :action => 'show'
+ body.show_public_body "/body/:url_name", :action => 'show'
end
map.with_options :controller => 'help' do |help|
diff --git a/spec/controllers/body_controller_spec.rb b/spec/controllers/body_controller_spec.rb
index 947c1de1c..672042f9b 100644
--- a/spec/controllers/body_controller_spec.rb
+++ b/spec/controllers/body_controller_spec.rb
@@ -5,23 +5,23 @@ describe BodyController, "when showing a body" do
fixtures :public_bodies, :public_body_versions
it "should be successful" do
- get :show, :simple_short_name => "dfh"
+ get :show, :url_name => "dfh"
response.should be_success
end
it "should render with 'show' template" do
- get :show, :simple_short_name => "dfh"
+ get :show, :url_name => "dfh"
response.should render_template('show')
end
it "should assign the body" do
- get :show, :simple_short_name => "dfh"
+ get :show, :url_name => "dfh"
assigns[:public_bodies].should == [ public_bodies(:humpadink_public_body) ]
end
it "should redirect to newest name if you use historic name of public body in URL" do
- get :show, :simple_short_name => "hdink"
- response.should redirect_to(:controller => 'body', :action => 'show', :simple_short_name => "dfh")
+ get :show, :url_name => "hdink"
+ response.should redirect_to(:controller => 'body', :action => 'show', :url_name => "dfh")
end
# XXX test for 404s when don't give valid name