mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Deprecated old render parameter calls
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@4947 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
This commit is contained in:
parent
315603e2be
commit
5048aa9831
3 changed files with 29 additions and 9 deletions
|
@ -29,7 +29,7 @@ Rake::TestTask.new(:test_action_pack) { |t|
|
|||
t.libs << "test"
|
||||
# make sure we include the controller tests (c*) first as on some systems
|
||||
# this will not happen automatically and the tests (as a whole) will error
|
||||
t.test_files=Dir.glob( "test/c*/*_test.rb" ) + Dir.glob( "test/[ft]*/*_test.rb" )
|
||||
t.test_files=Dir.glob( "test/c*/**/*_test.rb" ) + Dir.glob( "test/[ft]*/*_test.rb" )
|
||||
# t.pattern = 'test/*/*_test.rb'
|
||||
t.verbose = true
|
||||
}
|
||||
|
|
|
@ -490,7 +490,7 @@ module ActionController #:nodoc:
|
|||
|
||||
when Symbol
|
||||
ActiveSupport::Deprecation.warn(
|
||||
"WARNING: You called url_for(:#{options}), which is a deprecated API. Instead you should use the named " +
|
||||
"WARNING: 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."
|
||||
)
|
||||
|
||||
|
@ -671,12 +671,21 @@ module ActionController #:nodoc:
|
|||
def render(options = nil, deprecated_status = nil, &block) #:doc:
|
||||
raise DoubleRenderError, "Can only render or redirect once per action" if performed?
|
||||
|
||||
# Backwards compatibility
|
||||
unless options.is_a?(Hash)
|
||||
if options == :update
|
||||
options = {:update => true}
|
||||
else
|
||||
return render_file(options || default_template_name, deprecated_status, true)
|
||||
if options.nil?
|
||||
return render_file(default_template_name, deprecated_status, true)
|
||||
else
|
||||
# Backwards compatibility
|
||||
unless options.is_a?(Hash)
|
||||
if options == :update
|
||||
options = { :update => true }
|
||||
else
|
||||
ActiveSupport::Deprecation.warn(
|
||||
"WARNING: You called render('#{options}'), which is a deprecated API call. Instead you use " +
|
||||
"render :file => #{options}. Calling render with just a string will be removed from Rails 2.0."
|
||||
)
|
||||
|
||||
return render_file(options, deprecated_status, true)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@ class DeprecatedBaseMethodsTest < Test::Unit::TestCase
|
|||
end
|
||||
|
||||
def deprecated_render_parameters
|
||||
# render ""
|
||||
render "fun/games/hello_world"
|
||||
end
|
||||
|
||||
def home_url(greeting)
|
||||
|
@ -17,6 +17,8 @@ class DeprecatedBaseMethodsTest < Test::Unit::TestCase
|
|||
def rescue_action(e) raise e end
|
||||
end
|
||||
|
||||
Target.template_root = File.dirname(__FILE__) + "/../../fixtures"
|
||||
|
||||
def setup
|
||||
@request = ActionController::TestRequest.new
|
||||
@response = ActionController::TestResponse.new
|
||||
|
@ -27,6 +29,15 @@ class DeprecatedBaseMethodsTest < Test::Unit::TestCase
|
|||
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
|
||||
end
|
||||
|
||||
assert_equal "Living in a nested world", @response.body
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue