Permalink
Browse files

Remove hardcoded number_of_capturesin ControllerSegment to allow rege…

…xp requirements with capturing parentheses
  • Loading branch information...
1 parent ce41582 commit 51eb04c84c40bd9cdfeda3b14fa7048773329cba @pixeltrix pixeltrix committed with NZKoz Feb 22, 2009
Showing with 10 additions and 4 deletions.
  1. +0 −4 actionpack/lib/action_controller/routing/segments.rb
  2. +10 −0 actionpack/test/controller/routing_test.rb
@@ -240,10 +240,6 @@ def regexp_chunk
"(?i-:(#{(regexp || Regexp.union(*possible_names)).source}))"
end
- def number_of_captures
- 1
- end
-
# Don't URI.escape the controller name since it may contain slashes.
def interpolation_chunk(value_code = local_name)
"\#{#{value_code}.to_s}"
@@ -893,6 +893,16 @@ def test_route_with_regexp_for_controller
assert_equal '/content/foo', rs.generate(:controller => "content", :action => "foo")
end
+ def test_route_with_regexp_and_captures_for_controller
+ rs.draw do |map|
+ map.connect ':controller/:action/:id', :controller => /admin\/(accounts|users)/
+ end
+ assert_equal({:controller => "admin/accounts", :action => "index"}, rs.recognize_path("/admin/accounts"))
+ assert_equal({:controller => "admin/users", :action => "index"}, rs.recognize_path("/admin/users"))
+ assert_raises(ActionController::RoutingError) { rs.recognize_path("/admin/products") }
+ end
+
+
def test_route_with_regexp_and_dot
rs.draw do |map|
map.connect ':controller/:action/:file',

0 comments on commit 51eb04c

Please sign in to comment.