Deprecation: remove deprecated url_for(:symbol, *args) and redirect_to(:symbol, *args) controller methods. Use named routes instead.
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@6412 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
This commit is contained in:
parent
42f8e3f611
commit
f770165cc2
|
@ -1,6 +1,6 @@
|
|||
*SVN*
|
||||
|
||||
* Deprecation: remove deprecated request, redirect, and dependency methods. Remove deprecated instance variables. Remove uses_component_template_root for toplevel components directory. Privatize deprecated render_partial and render_partial_collection view methods. Remove deprecated link_to_image, link_image_to, update_element_function, start_form_tag, and end_form_tag helper methods. Remove deprecated human_size helper alias. [Jeremy Kemper]
|
||||
* Deprecation: remove deprecated request, redirect, and dependency methods. Remove deprecated instance variables. Remove deprecated url_for(:symbol, *args) and redirect_to(:symbol, *args) in favor of named routes. Remove uses_component_template_root for toplevel components directory. Privatize deprecated render_partial and render_partial_collection view methods. Remove deprecated link_to_image, link_image_to, update_element_function, start_form_tag, and end_form_tag helper methods. Remove deprecated human_size helper alias. [Jeremy Kemper]
|
||||
|
||||
* Consistent public/protected/private visibility for chained methods. #7813 [Dan Manges]
|
||||
|
||||
|
|
|
@ -553,22 +553,14 @@ module ActionController #:nodoc:
|
|||
#
|
||||
# This takes the current URL as is and only exchanges the action. In contrast, <tt>url_for :action => 'print'</tt>
|
||||
# would have slashed-off the path components after the changed action.
|
||||
def url_for(options = {}, *parameters_for_method_reference) #:doc:
|
||||
case options
|
||||
def url_for(options = nil) #:doc:
|
||||
case options || {}
|
||||
when String
|
||||
options
|
||||
|
||||
when Symbol
|
||||
ActiveSupport::Deprecation.warn(
|
||||
"You called url_for(:#{options}), which is a deprecated API call. Instead you should use the named " +
|
||||
"route directly, like #{options}(). Using symbols and parameters with url_for will be removed from Rails 2.0.",
|
||||
caller
|
||||
)
|
||||
|
||||
send(options, *parameters_for_method_reference)
|
||||
|
||||
when Hash
|
||||
@url.rewrite(rewrite_options(options))
|
||||
else
|
||||
raise ArgumentError, "Unrecognized url_for options: #{options.inspect}"
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -2,10 +2,6 @@ require File.dirname(__FILE__) + '/../../abstract_unit'
|
|||
|
||||
class DeprecatedBaseMethodsTest < Test::Unit::TestCase
|
||||
class Target < ActionController::Base
|
||||
def deprecated_symbol_parameter_to_url_for
|
||||
redirect_to(url_for(:home_url, "superstars"))
|
||||
end
|
||||
|
||||
def deprecated_render_parameters
|
||||
render "fun/games/hello_world"
|
||||
end
|
||||
|
@ -29,14 +25,6 @@ class DeprecatedBaseMethodsTest < Test::Unit::TestCase
|
|||
@controller = Target.new
|
||||
end
|
||||
|
||||
def test_deprecated_symbol_parameter_to_url_for
|
||||
assert_deprecated("url_for(:home_url)") do
|
||||
get :deprecated_symbol_parameter_to_url_for
|
||||
end
|
||||
|
||||
assert_redirected_to "http://example.com/superstars"
|
||||
end
|
||||
|
||||
def test_deprecated_render_parameters
|
||||
assert_deprecated("render('fun/games/hello_world')") do
|
||||
get :deprecated_render_parameters
|
||||
|
|
|
@ -5,10 +5,6 @@ class RedirectController < ActionController::Base
|
|||
redirect_to :action => "hello_world"
|
||||
end
|
||||
|
||||
def method_redirect
|
||||
redirect_to :dashbord_url, 1, "hello"
|
||||
end
|
||||
|
||||
def host_redirect
|
||||
redirect_to :action => "other_host", :only_path => false, :host => 'other.test.host'
|
||||
end
|
||||
|
@ -49,12 +45,6 @@ class RedirectTest < Test::Unit::TestCase
|
|||
assert_equal "http://test.host/redirect/hello_world", redirect_to_url
|
||||
end
|
||||
|
||||
def test_redirect_with_method_reference_and_parameters
|
||||
assert_deprecated(/redirect_to/) { get :method_redirect }
|
||||
assert_response :redirect
|
||||
assert_equal "http://test.host/redirect/dashboard/1?message=hello", redirect_to_url
|
||||
end
|
||||
|
||||
def test_simple_redirect_using_options
|
||||
get :host_redirect
|
||||
assert_response :redirect
|
||||
|
@ -129,12 +119,6 @@ module ModuleTest
|
|||
assert_equal "http://test.host/module_test/module_redirect/hello_world", redirect_to_url
|
||||
end
|
||||
|
||||
def test_redirect_with_method_reference_and_parameters
|
||||
assert_deprecated(/redirect_to/) { get :method_redirect }
|
||||
assert_response :redirect
|
||||
assert_equal "http://test.host/module_test/module_redirect/dashboard/1?message=hello", redirect_to_url
|
||||
end
|
||||
|
||||
def test_simple_redirect_using_options
|
||||
get :host_redirect
|
||||
assert_response :redirect
|
||||
|
|
|
@ -54,10 +54,6 @@ HTML
|
|||
render :text => params[:file].size
|
||||
end
|
||||
|
||||
def redirect_to_symbol
|
||||
redirect_to :generate_url, :id => 5
|
||||
end
|
||||
|
||||
def redirect_to_same_controller
|
||||
redirect_to :controller => 'test', :action => 'test_uri', :id => 5
|
||||
end
|
||||
|
@ -440,16 +436,6 @@ HTML
|
|||
assert_raise(RuntimeError) { ActionController::TestUploadedFile.new('non_existent_file') }
|
||||
end
|
||||
|
||||
def test_assert_redirected_to_symbol
|
||||
with_foo_routing do |set|
|
||||
assert_deprecated(/generate_url.*redirect_to/) do
|
||||
get :redirect_to_symbol
|
||||
end
|
||||
assert_response :redirect
|
||||
assert_redirected_to :generate_url
|
||||
end
|
||||
end
|
||||
|
||||
def test_assert_follow_redirect_to_same_controller
|
||||
with_foo_routing do |set|
|
||||
get :redirect_to_same_controller
|
||||
|
|
Loading…
Reference in New Issue