Permalink
Browse files

Routes: Convert results of #to_param to strings #879

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@947 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information...
1 parent 20e3cfe commit 0919dbf6b63a4aaa49a2855c37e79a90937290e1 @dhh dhh committed Mar 20, 2005
Showing with 8 additions and 1 deletion.
  1. +1 −1 actionpack/lib/action_controller/routing.rb
  2. +7 −0 actionpack/test/controller/routing_tests.rb
@@ -317,7 +317,7 @@ def draw
end
def self.extract_parameter_value(parameter)
- value = parameter.respond_to?(:to_param) ? parameter.to_param : parameter.to_s
+ value = (parameter.respond_to?(:to_param) ? parameter.to_param : parameter).to_s
CGI.escape(value)
end
@@ -346,6 +346,13 @@ def test_special_characters
verify_generate('id%2Fwith%2Fslashes', {},
{:controller => 'content', :action => 'fish', :id => 'id/with/slashes'}, {})
end
+
+ def test_generate_with_numeric_param
+ o = Object.new
+ def o.to_param() 10 end
+ verify_generate('content/action/10', {}, {:controller => 'content', :action => 'action', :id => o}, @defaults)
+ verify_generate('content/show/10', {}, {:controller => 'content', :action => 'show', :id => o}, @defaults)
+ end
end
class RouteSetTests < Test::Unit::TestCase

0 comments on commit 0919dbf

Please sign in to comment.