Skip to content

Commit

Permalink
Allow path => controller#action in Routes
Browse files Browse the repository at this point in the history
The `'path' => 'controller#action'` is a supported short-hand syntax
for Rails routes as documented [here][1]. The current type is too
restrictive and does not support this valid syntax. This change modifies
the first argument type so that it supports the Hash syntax.

[1]: https://github.com/rails/rails/blob/master/actionpack/lib/action_dispatch/routing/mapper.rb#L1605
  • Loading branch information
panthomakos committed Aug 8, 2019
1 parent 4c3f130 commit 62f749c
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
12 changes: 6 additions & 6 deletions lib/actionpack/all/actionpack.rbi
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ module ActionDispatch::Routing::Mapper::HttpHelpers
# ActionDispatch::Routing::Mapper::Resources#match
sig do
params(
name: T.any(String, Symbol),
name: T.any(String, Symbol, T::Hash[String, String]),
controller: T.nilable(T.any(String, Symbol)),
action: T.nilable(T.any(String, Symbol)),
param: T.nilable(Symbol),
Expand Down Expand Up @@ -148,7 +148,7 @@ module ActionDispatch::Routing::Mapper::HttpHelpers

sig do
params(
name: T.any(String, Symbol),
name: T.any(String, Symbol, T::Hash[String, String]),
controller: T.nilable(T.any(String, Symbol)),
action: T.nilable(T.any(String, Symbol)),
param: T.nilable(Symbol),
Expand Down Expand Up @@ -185,7 +185,7 @@ module ActionDispatch::Routing::Mapper::HttpHelpers

sig do
params(
name: T.any(String, Symbol),
name: T.any(String, Symbol, T::Hash[String, String]),
controller: T.nilable(T.any(String, Symbol)),
action: T.nilable(T.any(String, Symbol)),
param: T.nilable(Symbol),
Expand Down Expand Up @@ -222,7 +222,7 @@ module ActionDispatch::Routing::Mapper::HttpHelpers

sig do
params(
name: T.any(String, Symbol),
name: T.any(String, Symbol, T::Hash[String, String]),
controller: T.nilable(T.any(String, Symbol)),
action: T.nilable(T.any(String, Symbol)),
param: T.nilable(Symbol),
Expand Down Expand Up @@ -259,7 +259,7 @@ module ActionDispatch::Routing::Mapper::HttpHelpers

sig do
params(
name: T.any(String, Symbol),
name: T.any(String, Symbol, T::Hash[String, String]),
controller: T.nilable(T.any(String, Symbol)),
action: T.nilable(T.any(String, Symbol)),
param: T.nilable(Symbol),
Expand Down Expand Up @@ -304,7 +304,7 @@ module ActionDispatch::Routing::Mapper::Resources

sig do
params(
name: T.any(String, Symbol),
name: T.any(String, Symbol, T::Hash[String, String]),
controller: T.nilable(T.any(String, Symbol)),
action: T.nilable(T.any(String, Symbol)),
param: T.nilable(Symbol),
Expand Down
7 changes: 7 additions & 0 deletions lib/actionpack/test/actionpack_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,11 @@ module ActionPackTest
end

get '/about', to: 'static_pages#about'

delete 'about' => 'static_pages#about'
get 'about' => 'static_pages#about'
match 'about' => 'static_pages#about'
patch 'about' => 'static_pages#about'
post 'about' => 'static_pages#about'
put 'about' => 'static_pages#about'
end

0 comments on commit 62f749c

Please sign in to comment.