public
Fork of rails/rails
Description: Fork of Ruby on Rails for contributing patches.
Homepage: http://rubyonrails.org
Clone URL: git://github.com/seven1m/rails.git
Ensure routing generator works with non-string keys. [#172 state:resolved]


Make sure that (with recent correction to globbed parameter escaping) 
non-string
values can still be passed route generation helpers for globbed route 
segments.

For example, foo_path([1, 2, 3]) should still work for a route like 
map.foo "*globbed"
by implicitely calling to_s on the Fixnums.

Signed-off-by: Pratik Naik <pratiknaik@gmail.com>
svenfuchs (author)
Tue May 13 13:04:20 -0700 2008
lifo (committer)
Fri May 16 09:36:09 -0700 2008
commit  345f030c5b6c0a28ddde56c80a1112b00d345c79
tree    710430c54edfa4c1f145fdad150ea184fc2cc0d1
parent  77f873acf2f1fb4533dfca6b26b965a115ebbc54
...
249
250
251
252
 
253
254
255
...
249
250
251
 
252
253
254
255
0
@@ -249,7 +249,7 @@ module ActionController
0
       end
0
 
0
       def extract_value
0
- "#{local_name} = hash[:#{key}] && hash[:#{key}].collect { |path_component| URI.escape(path_component, ActionController::Routing::Segment::UNSAFE_PCHAR) }.to_param #{"|| #{default.inspect}" if default}"
0
+ "#{local_name} = hash[:#{key}] && hash[:#{key}].collect { |path_component| URI.escape(path_component.to_param, ActionController::Routing::Segment::UNSAFE_PCHAR) }.to_param #{"|| #{default.inspect}" if default}"
0
       end
0
 
0
       def default
...
50
51
52
 
 
 
 
 
 
 
53
54
55
...
50
51
52
53
54
55
56
57
58
59
60
61
62
0
@@ -50,6 +50,13 @@ class UriReservedCharactersRoutingTest < Test::Unit::TestCase
0
                 :additional => ["add#{@segment}itional-1", "add#{@segment}itional-2"] }
0
     assert_equal options, @set.recognize_path("/controller/act#{@escaped}ion/var#{@escaped}iable/add#{@escaped}itional-1/add#{@escaped}itional-2")
0
   end
0
+
0
+ def test_route_generation_allows_passing_non_string_values_to_generated_helper
0
+ assert_equal "/controller/action/variable/1/2", @set.generate(:controller => "controller",
0
+ :action => "action",
0
+ :variable => "variable",
0
+ :additional => [1, 2])
0
+ end
0
 end
0
 
0
 class LegacyRouteSetTests < Test::Unit::TestCase

Comments

    No one has commented yet.