Skip to content

Commit e4cfd35

Browse files
committed
Remove deprecated option use_route in controller tests
1 parent 755dcd0 commit e4cfd35

File tree

4 files changed

+5
-63
lines changed

4 files changed

+5
-63
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 option `use_route` in controller tests.
2+
3+
*Rafael Mendonça França*
4+
15
* Ensure `append_info_to_payload` is called even if an exception is raised.
26

37
Fixes an issue where when an exception is raised in the request the additonal

actionpack/lib/action_controller/test_case.rb

Lines changed: 1 addition & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
require 'active_support/core_ext/object/to_query'
33
require 'active_support/core_ext/module/anonymous'
44
require 'active_support/core_ext/hash/keys'
5-
require 'active_support/deprecation'
65

76
require 'rails-dom-testing'
87

@@ -714,28 +713,7 @@ def build_request_uri(action, parameters)
714713
:relative_url_root => nil,
715714
:_recall => @request.path_parameters)
716715

717-
if route_name = options.delete(:use_route)
718-
ActiveSupport::Deprecation.warn <<-MSG.squish
719-
Passing the `use_route` option in functional tests are deprecated.
720-
Support for this option in the `process` method (and the related
721-
`get`, `head`, `post`, `patch`, `put` and `delete` helpers) will
722-
be removed in the next version without replacement.
723-
724-
Functional tests are essentially unit tests for controllers and
725-
they should not require knowledge to how the application's routes
726-
are configured. Instead, you should explicitly pass the appropiate
727-
params to the `process` method.
728-
729-
Previously the engines guide also contained an incorrect example
730-
that recommended using this option to test an engine's controllers
731-
within the dummy application. That recommendation was incorrect
732-
and has since been corrected. Instead, you should override the
733-
`@routes` variable in the test case with `Foo::Engine.routes`. See
734-
the updated engines guide for details.
735-
MSG
736-
end
737-
738-
url, query_string = @routes.path_for(options, route_name).split("?", 2)
716+
url, query_string = @routes.path_for(options).split("?", 2)
739717

740718
@request.env["SCRIPT_NAME"] = @controller.config.relative_url_root
741719
@request.env["PATH_INFO"] = url

actionpack/lib/action_dispatch/journey/formatter.rb

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
require 'action_controller/metal/exceptions'
2-
require 'active_support/deprecation'
32

43
module ActionDispatch
54
module Journey
@@ -81,9 +80,6 @@ def match_route(name, options)
8180
if named_routes.key?(name)
8281
yield named_routes[name]
8382
else
84-
# Make sure we don't show the deprecation warning more than once
85-
warned = false
86-
8783
routes = non_recursive(cache, options)
8884

8985
hash = routes.group_by { |_, r| r.score(options) }
@@ -92,17 +88,6 @@ def match_route(name, options)
9288
break if score < 0
9389

9490
hash[score].sort_by { |i, _| i }.each do |_, route|
95-
if name && !warned
96-
ActiveSupport::Deprecation.warn <<-MSG.squish
97-
You are trying to generate the URL for a named route called
98-
#{name.inspect} but no such route was found. In the future,
99-
this will result in an `ActionController::UrlGenerationError`
100-
exception.
101-
MSG
102-
103-
warned = true
104-
end
105-
10691
yield route
10792
end
10893
end

actionpack/test/controller/test_case_test.rb

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -521,18 +521,6 @@ def test_array_path_parameter_handled_properly
521521
end
522522
end
523523

524-
def test_use_route
525-
with_routing do |set|
526-
set.draw do
527-
get 'via_unnamed_route', to: 'test_case_test/test#test_uri'
528-
get 'via_named_route', as: :a_named_route, to: 'test_case_test/test#test_uri'
529-
end
530-
531-
assert_deprecated { get :test_uri, use_route: :a_named_route }
532-
assert_equal '/via_named_route', @response.body
533-
end
534-
end
535-
536524
def test_assert_realistic_path_parameters
537525
get :test_params, :id => 20, :foo => Object.new
538526

@@ -790,19 +778,6 @@ def test_engine_controller_route
790778
assert_equal @response.body, 'bar'
791779
end
792780
end
793-
794-
class BarControllerTestWithHostApplicationRouteSet < ActionController::TestCase
795-
tests BarController
796-
797-
def test_use_route
798-
with_routing do |set|
799-
set.draw { mount Engine => '/foo' }
800-
801-
assert_deprecated { get :index, use_route: :foo }
802-
assert_equal @response.body, 'bar'
803-
end
804-
end
805-
end
806781
end
807782

808783
class InferringClassNameTest < ActionController::TestCase

0 commit comments

Comments
 (0)