1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Deprecation: remove deprecated update_element_function, start_form_tag, and end_form_tag. Use RJS and form_tag instead.

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@6409 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
This commit is contained in:
Jeremy Kemper 2007-03-13 05:24:10 +00:00
parent e3dab67c44
commit 1def3f0073
6 changed files with 4 additions and 122 deletions

View file

@ -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 and link_image_to helper methods. Remove deprecated human_size helper alias. [Jeremy Kemper]
* 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]
* Consistent public/protected/private visibility for chained methods. #7813 [Dan Manges]

View file

@ -1,34 +0,0 @@
module ActionView
module Helpers
module PrototypeHelper
def update_element_function(element_id, options = {}, &block)
content = escape_javascript(options[:content] || '')
content = escape_javascript(capture(&block)) if block
javascript_function = case (options[:action] || :update)
when :update
if options[:position]
"new Insertion.#{options[:position].to_s.camelize}('#{element_id}','#{content}')"
else
"$('#{element_id}').innerHTML = '#{content}'"
end
when :empty
"$('#{element_id}').innerHTML = ''"
when :remove
"Element.remove('#{element_id}')"
else
raise ArgumentError, "Invalid action, choose one of :update, :remove, :empty"
end
javascript_function << ";\n"
options[:binding] ? concat(javascript_function, options[:binding]) : javascript_function
end
deprecate :update_element_function => "use RJS instead"
end
end
end

View file

@ -39,14 +39,6 @@ module ActionView
end
end
alias_method :start_form_tag, :form_tag
# Outputs "</form>"
def end_form_tag
"</form>"
end
deprecate :end_form_tag, :start_form_tag => :form_tag
# Creates a dropdown selection box, or if the <tt>:multiple</tt> option is set to true, a multiple
# choice selection box.

View file

@ -64,19 +64,8 @@ class CaptureTest < Test::Unit::TestCase
assert_equal expected_content_for_output, @response.body
end
def test_update_element_with_capture
assert_deprecated 'update_element_function' do
get :update_element_with_capture
end
assert_equal(
"<script type=\"text/javascript\">\n//<![CDATA[\n$('products').innerHTML = '\\n <p>Product 1</p>\\n <p>Product 2</p>\\n';\n\n//]]>\n</script>" +
"\n\n$('status').innerHTML = '\\n <b>You bought something!</b>\\n';",
@response.body.strip
)
end
private
def expected_content_for_output
"<title>Putting stuff in the title!</title>\n\nGreat stuff!"
end
def expected_content_for_output
"<title>Putting stuff in the title!</title>\n\nGreat stuff!"
end
end

View file

@ -1,36 +0,0 @@
require "#{File.dirname(__FILE__)}/../abstract_unit"
class DeprecatedHelperTest < Test::Unit::TestCase
include ActionView::Helpers::JavaScriptHelper
include ActionView::Helpers::CaptureHelper
def test_update_element_function
assert_deprecated 'update_element_function' do
assert_equal %($('myelement').innerHTML = 'blub';\n),
update_element_function('myelement', :content => 'blub')
assert_equal %($('myelement').innerHTML = 'blub';\n),
update_element_function('myelement', :action => :update, :content => 'blub')
assert_equal %($('myelement').innerHTML = '';\n),
update_element_function('myelement', :action => :empty)
assert_equal %(Element.remove('myelement');\n),
update_element_function('myelement', :action => :remove)
assert_equal %(new Insertion.Bottom('myelement','blub');\n),
update_element_function('myelement', :position => 'bottom', :content => 'blub')
assert_equal %(new Insertion.Bottom('myelement','blub');\n),
update_element_function('myelement', :action => :update, :position => :bottom, :content => 'blub')
_erbout = ""
assert_equal %($('myelement').innerHTML = 'test';\n),
update_element_function('myelement') { _erbout << "test" }
_erbout = ""
assert_equal %($('myelement').innerHTML = 'blockstuff';\n),
update_element_function('myelement', :content => 'paramstuff') { _erbout << "blockstuff" }
end
end
end

View file

@ -147,32 +147,3 @@ class FormTagHelperTest < Test::Unit::TestCase
assert_equal 1, 1
end
end
class DeprecatedFormTagHelperTest < Test::Unit::TestCase
include ActionView::Helpers::UrlHelper
include ActionView::Helpers::TagHelper
include ActionView::Helpers::FormTagHelper
include ActionView::Helpers::TextHelper
include ActionView::Helpers::CaptureHelper
def setup
@controller = Class.new do
def url_for(options, *parameters_for_method_reference)
"http://www.example.com"
end
end
@controller = @controller.new
end
def test_start_form_tag_deprecation
assert_deprecated /start_form_tag/ do
start_form_tag
end
end
def test_end_form_tag_deprecation
assert_deprecated /end_form_tag/ do
end_form_tag
end
end
end