Skip to content

Commit

Permalink
Remove deprecated option use_route in controller tests
Browse files Browse the repository at this point in the history
  • Loading branch information
rafaelfranca committed Jan 4, 2015
1 parent 755dcd0 commit e4cfd35
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 63 deletions.
4 changes: 4 additions & 0 deletions actionpack/CHANGELOG.md
Original file line number Original file line Diff line number Diff line change
@@ -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. * 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 Fixes an issue where when an exception is raised in the request the additonal
Expand Down
24 changes: 1 addition & 23 deletions actionpack/lib/action_controller/test_case.rb
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
require 'active_support/core_ext/object/to_query' require 'active_support/core_ext/object/to_query'
require 'active_support/core_ext/module/anonymous' require 'active_support/core_ext/module/anonymous'
require 'active_support/core_ext/hash/keys' require 'active_support/core_ext/hash/keys'
require 'active_support/deprecation'


require 'rails-dom-testing' require 'rails-dom-testing'


Expand Down Expand Up @@ -714,28 +713,7 @@ def build_request_uri(action, parameters)
:relative_url_root => nil, :relative_url_root => nil,
:_recall => @request.path_parameters) :_recall => @request.path_parameters)


if route_name = options.delete(:use_route) url, query_string = @routes.path_for(options).split("?", 2)
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)


@request.env["SCRIPT_NAME"] = @controller.config.relative_url_root @request.env["SCRIPT_NAME"] = @controller.config.relative_url_root
@request.env["PATH_INFO"] = url @request.env["PATH_INFO"] = url
Expand Down
15 changes: 0 additions & 15 deletions actionpack/lib/action_dispatch/journey/formatter.rb
Original file line number Original file line Diff line number Diff line change
@@ -1,5 +1,4 @@
require 'action_controller/metal/exceptions' require 'action_controller/metal/exceptions'
require 'active_support/deprecation'


module ActionDispatch module ActionDispatch
module Journey module Journey
Expand Down Expand Up @@ -81,9 +80,6 @@ def match_route(name, options)
if named_routes.key?(name) if named_routes.key?(name)
yield named_routes[name] yield named_routes[name]
else else
# Make sure we don't show the deprecation warning more than once
warned = false

routes = non_recursive(cache, options) routes = non_recursive(cache, options)


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


hash[score].sort_by { |i, _| i }.each do |_, route| 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 yield route
end end
end end
Expand Down
25 changes: 0 additions & 25 deletions actionpack/test/controller/test_case_test.rb
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -521,18 +521,6 @@ def test_array_path_parameter_handled_properly
end end
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 def test_assert_realistic_path_parameters
get :test_params, :id => 20, :foo => Object.new get :test_params, :id => 20, :foo => Object.new


Expand Down Expand Up @@ -790,19 +778,6 @@ def test_engine_controller_route
assert_equal @response.body, 'bar' assert_equal @response.body, 'bar'
end end
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 end


class InferringClassNameTest < ActionController::TestCase class InferringClassNameTest < ActionController::TestCase
Expand Down

0 comments on commit e4cfd35

Please sign in to comment.