From 0d88e980a9e6fe53037c85c05cb5c3b08112a61a Mon Sep 17 00:00:00 2001 From: Sven Fuchs Date: Tue, 13 May 2008 22:04:20 +0200 Subject: [PATCH] Make sure that (with recent correction to globbed parameter escaping) non-string values can still be passed route generation helpers for globbed route segments. I.e. foo_path([1, 2, 3]) should still work for a route like map.foo "*globbed" by implicitely calling to_s on the Fixnums. --- .../lib/action_controller/routing/segments.rb | 2 +- actionpack/test/controller/routing_test.rb | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletions(-) diff --git a/actionpack/lib/action_controller/routing/segments.rb b/actionpack/lib/action_controller/routing/segments.rb index b142d18..9b1d014 100644 --- a/actionpack/lib/action_controller/routing/segments.rb +++ b/actionpack/lib/action_controller/routing/segments.rb @@ -249,7 +249,7 @@ module ActionController end def extract_value - "#{local_name} = hash[:#{key}] && hash[:#{key}].collect { |path_component| URI.escape(path_component, ActionController::Routing::Segment::UNSAFE_PCHAR) }.to_param #{"|| #{default.inspect}" if default}" + "#{local_name} = hash[:#{key}] && hash[:#{key}].collect { |path_component| URI.escape(path_component.to_s, ActionController::Routing::Segment::UNSAFE_PCHAR) }.to_param #{"|| #{default.inspect}" if default}" end def default diff --git a/actionpack/test/controller/routing_test.rb b/actionpack/test/controller/routing_test.rb index b28f7bc..faef591 100644 --- a/actionpack/test/controller/routing_test.rb +++ b/actionpack/test/controller/routing_test.rb @@ -50,6 +50,13 @@ class UriReservedCharactersRoutingTest < Test::Unit::TestCase :additional => ["add#{@segment}itional-1", "add#{@segment}itional-2"] } assert_equal options, @set.recognize_path("/controller/act#{@escaped}ion/var#{@escaped}iable/add#{@escaped}itional-1/add#{@escaped}itional-2") end + + def test_route_generation_allows_passing_non_string_values_to_generated_helper + assert_nothing_raised { @set.generate(:controller => "controller", + :action => "action", + :variable => "variable", + :additional => [1, 2]) } + end end class LegacyRouteSetTests < Test::Unit::TestCase -- 1.5.3.7