aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack
diff options
context:
space:
mode:
authorAndrew White <andyw@pixeltrix.co.uk>2009-02-07 14:44:50 +0000
committerMichael Koziarski <michael@koziarski.com>2009-02-22 15:34:01 +1300
commitf7a0a394f48a0f21e686f891546d17ce33c7840e (patch)
tree0bf8a188b9c297ef004b49ad4f9b312bb00f62fc /actionpack
parentfc09ebc669bd58f415f7d3ef932ef02dab821ab5 (diff)
downloadrails-f7a0a394f48a0f21e686f891546d17ce33c7840e.tar.gz
rails-f7a0a394f48a0f21e686f891546d17ce33c7840e.tar.bz2
rails-f7a0a394f48a0f21e686f891546d17ce33c7840e.zip
Remove hardcoded number_of_capturesin ControllerSegment to allow regexp requirements with capturing parentheses
Signed-off-by: Michael Koziarski <michael@koziarski.com> [#1887 state:committed]
Diffstat (limited to 'actionpack')
-rw-r--r--actionpack/lib/action_controller/routing/segments.rb4
-rw-r--r--actionpack/test/controller/routing_test.rb9
2 files changed, 9 insertions, 4 deletions
diff --git a/actionpack/lib/action_controller/routing/segments.rb b/actionpack/lib/action_controller/routing/segments.rb
index 5dda3d4d00..a5e3b95f31 100644
--- a/actionpack/lib/action_controller/routing/segments.rb
+++ b/actionpack/lib/action_controller/routing/segments.rb
@@ -244,10 +244,6 @@ module ActionController
"(?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}"
diff --git a/actionpack/test/controller/routing_test.rb b/actionpack/test/controller/routing_test.rb
index 1caed33c59..d3fe62e28e 100644
--- a/actionpack/test/controller/routing_test.rb
+++ b/actionpack/test/controller/routing_test.rb
@@ -852,6 +852,15 @@ class LegacyRouteSetTests < Test::Unit::TestCase
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',