Permalink
Browse files

Remove deprecated option `use_route` in controller tests

  • Loading branch information...
rafaelfranca committed Jan 3, 2015
1 parent 755dcd0 commit e4cfd353a47369dd32198b0e67b8cbb2f9a1c548
View
@@ -1,3 +1,7 @@
* Remove deprecated option `use_route` in controller tests.
*Rafael Mendonça França*
* Ensure `append_info_to_payload` is called even if an exception is raised.
Fixes an issue where when an exception is raised in the request the additonal
@@ -2,7 +2,6 @@
require 'active_support/core_ext/object/to_query'
require 'active_support/core_ext/module/anonymous'
require 'active_support/core_ext/hash/keys'
require 'active_support/deprecation'
require 'rails-dom-testing'
@@ -714,28 +713,7 @@ def build_request_uri(action, parameters)
:relative_url_root => nil,
:_recall => @request.path_parameters)
if route_name = options.delete(:use_route)
ActiveSupport::Deprecation.warn <<-MSG.squish
Passing the `use_route` option in functional tests are deprecated.
Support for this option in the `process` method (and the related
`get`, `head`, `post`, `patch`, `put` and `delete` helpers) will
be removed in the next version without replacement.
Functional tests are essentially unit tests for controllers and
they should not require knowledge to how the application's routes
are configured. Instead, you should explicitly pass the appropiate
params to the `process` method.
Previously the engines guide also contained an incorrect example
that recommended using this option to test an engine's controllers
within the dummy application. That recommendation was incorrect
and has since been corrected. Instead, you should override the
`@routes` variable in the test case with `Foo::Engine.routes`. See
the updated engines guide for details.
MSG
end
url, query_string = @routes.path_for(options, route_name).split("?", 2)
url, query_string = @routes.path_for(options).split("?", 2)
@request.env["SCRIPT_NAME"] = @controller.config.relative_url_root
@request.env["PATH_INFO"] = url
@@ -1,5 +1,4 @@
require 'action_controller/metal/exceptions'
require 'active_support/deprecation'
module ActionDispatch
module Journey
@@ -81,9 +80,6 @@ def match_route(name, options)
if named_routes.key?(name)
yield named_routes[name]
else
# Make sure we don't show the deprecation warning more than once
warned = false
routes = non_recursive(cache, options)
hash = routes.group_by { |_, r| r.score(options) }
@@ -92,17 +88,6 @@ def match_route(name, options)
break if score < 0
hash[score].sort_by { |i, _| i }.each do |_, route|
if name && !warned
ActiveSupport::Deprecation.warn <<-MSG.squish
You are trying to generate the URL for a named route called
#{name.inspect} but no such route was found. In the future,
this will result in an `ActionController::UrlGenerationError`
exception.
MSG
warned = true
end
yield route
end
end
@@ -521,18 +521,6 @@ def test_array_path_parameter_handled_properly
end
end
def test_use_route
with_routing do |set|
set.draw do
get 'via_unnamed_route', to: 'test_case_test/test#test_uri'
get 'via_named_route', as: :a_named_route, to: 'test_case_test/test#test_uri'
end
assert_deprecated { get :test_uri, use_route: :a_named_route }
assert_equal '/via_named_route', @response.body
end
end
def test_assert_realistic_path_parameters
get :test_params, :id => 20, :foo => Object.new
@@ -790,19 +778,6 @@ def test_engine_controller_route
assert_equal @response.body, 'bar'
end
end
class BarControllerTestWithHostApplicationRouteSet < ActionController::TestCase
tests BarController
def test_use_route
with_routing do |set|
set.draw { mount Engine => '/foo' }
assert_deprecated { get :index, use_route: :foo }
assert_equal @response.body, 'bar'
end
end
end
end
class InferringClassNameTest < ActionController::TestCase

0 comments on commit e4cfd35

Please sign in to comment.