Skip to content

Commit 1f3b0a8

Browse files
committed
Remove deprecated support to define routes with :to option that
doesn't contain `#`
1 parent 4b19d5b commit 1f3b0a8

File tree

3 files changed

+10
-47
lines changed

3 files changed

+10
-47
lines changed

actionpack/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
* Remove deprecated support to define routes with `:to` option that doesn't contain `#`.
2+
3+
*Rafael Mendonça França*
4+
15
* Remove deprecated `ActionDispatch::Response#to_ary`.
26

37
*Rafael Mendonça França*

actionpack/lib/action_dispatch/routing/mapper.rb

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
require 'active_support/inflector'
99
require 'action_dispatch/routing/redirection'
1010
require 'action_dispatch/routing/endpoint'
11-
require 'active_support/deprecation'
1211

1312
module ActionDispatch
1413
module Routing
@@ -279,22 +278,8 @@ def check_part(name, part, path_params, hash)
279278
end
280279

281280
def split_to(to)
282-
case to
283-
when Symbol
284-
ActiveSupport::Deprecation.warn(<<-MSG.squish)
285-
Defining a route where `to` is a symbol is deprecated.
286-
Please change `to: :#{to}` to `action: :#{to}`.
287-
MSG
288-
289-
[nil, to.to_s]
290-
when /#/ then to.split('#')
291-
when String
292-
ActiveSupport::Deprecation.warn(<<-MSG.squish)
293-
Defining a route where `to` is a controller without an action is deprecated.
294-
Please change `to: :#{to}` to `controller: :#{to}`.
295-
MSG
296-
297-
[to, nil]
281+
if to =~ /#/
282+
to.split('#')
298283
else
299284
[]
300285
end

actionpack/test/dispatch/routing_test.rb

Lines changed: 4 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -3331,30 +3331,6 @@ def test_mix_string_to_action
33313331
assert_equal 'comments#index', @response.body
33323332
end
33333333

3334-
def test_mix_symbol_to_controller_action
3335-
assert_deprecated do
3336-
draw do
3337-
get '/projects', controller: 'project_files',
3338-
action: 'index',
3339-
to: :show
3340-
end
3341-
end
3342-
get '/projects'
3343-
assert_equal 'project_files#show', @response.body
3344-
end
3345-
3346-
def test_mix_string_to_controller_action_no_hash
3347-
assert_deprecated do
3348-
draw do
3349-
get '/projects', controller: 'project_files',
3350-
action: 'index',
3351-
to: 'show'
3352-
end
3353-
end
3354-
get '/projects'
3355-
assert_equal 'show#index', @response.body
3356-
end
3357-
33583334
def test_shallow_path_and_prefix_are_not_added_to_non_shallow_routes
33593335
draw do
33603336
scope shallow_path: 'projects', shallow_prefix: 'project' do
@@ -3629,15 +3605,13 @@ def test_missing_controller
36293605
assert_match(/Missing :controller/, ex.message)
36303606
end
36313607

3632-
def test_missing_action
3608+
def test_missing_controller_with_to
36333609
ex = assert_raises(ArgumentError) {
3634-
assert_deprecated do
3635-
draw do
3636-
get '/foo/bar', :to => 'foo'
3637-
end
3610+
draw do
3611+
get '/foo/bar', :to => 'foo'
36383612
end
36393613
}
3640-
assert_match(/Missing :action/, ex.message)
3614+
assert_match(/Missing :controller/, ex.message)
36413615
end
36423616

36433617
def test_missing_action_on_hash

0 commit comments

Comments
 (0)