mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Remove deprecated support to define routes with :to
option that
doesn't contain `#`
This commit is contained in:
parent
4b19d5b7bc
commit
1f3b0a8609
3 changed files with 10 additions and 47 deletions
|
@ -1,3 +1,7 @@
|
||||||
|
* Remove deprecated support to define routes with `:to` option that doesn't contain `#`.
|
||||||
|
|
||||||
|
*Rafael Mendonça França*
|
||||||
|
|
||||||
* Remove deprecated `ActionDispatch::Response#to_ary`.
|
* Remove deprecated `ActionDispatch::Response#to_ary`.
|
||||||
|
|
||||||
*Rafael Mendonça França*
|
*Rafael Mendonça França*
|
||||||
|
|
|
@ -8,7 +8,6 @@ require 'active_support/core_ext/string/filters'
|
||||||
require 'active_support/inflector'
|
require 'active_support/inflector'
|
||||||
require 'action_dispatch/routing/redirection'
|
require 'action_dispatch/routing/redirection'
|
||||||
require 'action_dispatch/routing/endpoint'
|
require 'action_dispatch/routing/endpoint'
|
||||||
require 'active_support/deprecation'
|
|
||||||
|
|
||||||
module ActionDispatch
|
module ActionDispatch
|
||||||
module Routing
|
module Routing
|
||||||
|
@ -279,22 +278,8 @@ module ActionDispatch
|
||||||
end
|
end
|
||||||
|
|
||||||
def split_to(to)
|
def split_to(to)
|
||||||
case to
|
if to =~ /#/
|
||||||
when Symbol
|
to.split('#')
|
||||||
ActiveSupport::Deprecation.warn(<<-MSG.squish)
|
|
||||||
Defining a route where `to` is a symbol is deprecated.
|
|
||||||
Please change `to: :#{to}` to `action: :#{to}`.
|
|
||||||
MSG
|
|
||||||
|
|
||||||
[nil, to.to_s]
|
|
||||||
when /#/ then to.split('#')
|
|
||||||
when String
|
|
||||||
ActiveSupport::Deprecation.warn(<<-MSG.squish)
|
|
||||||
Defining a route where `to` is a controller without an action is deprecated.
|
|
||||||
Please change `to: :#{to}` to `controller: :#{to}`.
|
|
||||||
MSG
|
|
||||||
|
|
||||||
[to, nil]
|
|
||||||
else
|
else
|
||||||
[]
|
[]
|
||||||
end
|
end
|
||||||
|
|
|
@ -3331,30 +3331,6 @@ class TestRoutingMapper < ActionDispatch::IntegrationTest
|
||||||
assert_equal 'comments#index', @response.body
|
assert_equal 'comments#index', @response.body
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_mix_symbol_to_controller_action
|
|
||||||
assert_deprecated do
|
|
||||||
draw do
|
|
||||||
get '/projects', controller: 'project_files',
|
|
||||||
action: 'index',
|
|
||||||
to: :show
|
|
||||||
end
|
|
||||||
end
|
|
||||||
get '/projects'
|
|
||||||
assert_equal 'project_files#show', @response.body
|
|
||||||
end
|
|
||||||
|
|
||||||
def test_mix_string_to_controller_action_no_hash
|
|
||||||
assert_deprecated do
|
|
||||||
draw do
|
|
||||||
get '/projects', controller: 'project_files',
|
|
||||||
action: 'index',
|
|
||||||
to: 'show'
|
|
||||||
end
|
|
||||||
end
|
|
||||||
get '/projects'
|
|
||||||
assert_equal 'show#index', @response.body
|
|
||||||
end
|
|
||||||
|
|
||||||
def test_shallow_path_and_prefix_are_not_added_to_non_shallow_routes
|
def test_shallow_path_and_prefix_are_not_added_to_non_shallow_routes
|
||||||
draw do
|
draw do
|
||||||
scope shallow_path: 'projects', shallow_prefix: 'project' do
|
scope shallow_path: 'projects', shallow_prefix: 'project' do
|
||||||
|
@ -3629,15 +3605,13 @@ class TestNamespaceWithControllerOption < ActionDispatch::IntegrationTest
|
||||||
assert_match(/Missing :controller/, ex.message)
|
assert_match(/Missing :controller/, ex.message)
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_missing_action
|
def test_missing_controller_with_to
|
||||||
ex = assert_raises(ArgumentError) {
|
ex = assert_raises(ArgumentError) {
|
||||||
assert_deprecated do
|
draw do
|
||||||
draw do
|
get '/foo/bar', :to => 'foo'
|
||||||
get '/foo/bar', :to => 'foo'
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
}
|
}
|
||||||
assert_match(/Missing :action/, ex.message)
|
assert_match(/Missing :controller/, ex.message)
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_missing_action_on_hash
|
def test_missing_action_on_hash
|
||||||
|
|
Loading…
Reference in a new issue