Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

`RoutesInspector` deals with routes using regexp as `:controller` option #10785

Merged
merged 1 commit into from May 30, 2013

Conversation

Projects
None yet
3 participants
Member

senny commented May 29, 2013

Fixes #10782.

Simple patch to make the RoutesInspector cope with regexp values for the :controller option.

Member

senny commented May 29, 2013

@rafaelfranca @carlosantoniodasilva can you take a look?

Owner

rafaelfranca commented May 29, 2013

I'm not sure if we should support this. Will these routes be matched?

@carlosantoniodasilva carlosantoniodasilva commented on an outdated diff May 30, 2013

actionpack/CHANGELOG.md
@@ -1,3 +1,13 @@
+* `ActionDispatch::Routing::RoutesInspector` knows how to deal with routes
+ using a regex as `:controller` option.
+ Fixes #10782.
+
+ Example:
+
+ get ':controller(/:action)', controller: /api\/[^\/]+/, format: false
+
+ *Yves Senn*
+
@carlosantoniodasilva

carlosantoniodasilva May 30, 2013

Owner

I think it's not necessary to add a changelog entry for this bug fix, even if we're going to backport it.

@carlosantoniodasilva carlosantoniodasilva commented on an outdated diff May 30, 2013

actionpack/test/dispatch/routing/inspector_test.rb
@@ -234,6 +234,16 @@ def test_routes_can_be_filtered
" PUT /posts/:id(.:format) posts#update",
" DELETE /posts/:id(.:format) posts#destroy"], output
end
+
+ def test_regression_route_with_controller_regexp
+ output = draw do
+ get ':controller(/:action)', controller: /api\/[^\/]+/, format: false
+ end
+
+ assert_equal ["Prefix Verb URI Pattern Controller#Action",
+ " GET /:controller(/:action) (?-mix:api\\/[^\\/]+)#:action"], output
+ end
+
Member

senny commented May 30, 2013

@carlosantoniodasilva I removed the blank line and the CHANGELOG entry.

@rafaelfranca rafaelfranca added a commit that referenced this pull request May 30, 2013

@rafaelfranca rafaelfranca Merge pull request #10785 from senny/10782_routes_inspector_deals_wit…
…h_controller_regexp

`RoutesInspector` deals with routes using regexp as `:controller` option
6a6eae2

@rafaelfranca rafaelfranca merged commit 6a6eae2 into rails:master May 30, 2013

@rafaelfranca rafaelfranca added a commit that referenced this pull request May 30, 2013

@rafaelfranca rafaelfranca Merge pull request #10785 from senny/10782_routes_inspector_deals_wit…
…h_controller_regexp

`RoutesInspector` deals with routes using regexp as `:controller` option
bf2542b

@rafaelfranca rafaelfranca added a commit that referenced this pull request May 30, 2013

@rafaelfranca rafaelfranca Merge pull request #10785 from senny/10782_routes_inspector_deals_wit…
…h_controller_regexp

`RoutesInspector` deals with routes using regexp as `:controller` option
decfa35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment