From 62f749c76d117f7d5f1cfb99244c0490a4fee5ed Mon Sep 17 00:00:00 2001 From: Pan Thomakos Date: Tue, 6 Aug 2019 08:59:18 -0700 Subject: [PATCH] Allow path => controller#action in Routes 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 --- lib/actionpack/all/actionpack.rbi | 12 ++++++------ lib/actionpack/test/actionpack_test.rb | 7 +++++++ 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/lib/actionpack/all/actionpack.rbi b/lib/actionpack/all/actionpack.rbi index 2dad1e6a..27edfcb6 100644 --- a/lib/actionpack/all/actionpack.rbi +++ b/lib/actionpack/all/actionpack.rbi @@ -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), @@ -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), @@ -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), @@ -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), @@ -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), @@ -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), diff --git a/lib/actionpack/test/actionpack_test.rb b/lib/actionpack/test/actionpack_test.rb index c523c892..3f61ae65 100644 --- a/lib/actionpack/test/actionpack_test.rb +++ b/lib/actionpack/test/actionpack_test.rb @@ -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