From d69e5616e821afc40efa5936c5ab6e087eb4e0c6 Mon Sep 17 00:00:00 2001 From: Joshua Peek Date: Tue, 16 Mar 2010 22:06:16 -0500 Subject: link_to_function is here to stay --- actionpack/test/template/javascript_helper_test.rb | 31 +++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) (limited to 'actionpack/test/template/javascript_helper_test.rb') diff --git a/actionpack/test/template/javascript_helper_test.rb b/actionpack/test/template/javascript_helper_test.rb index f49b763881..c5c2a6b952 100644 --- a/actionpack/test/template/javascript_helper_test.rb +++ b/actionpack/test/template/javascript_helper_test.rb @@ -17,7 +17,7 @@ class JavaScriptHelperTest < ActionView::TestCase ActiveSupport.escape_html_entities_in_json = true @template = self end - + def teardown ActiveSupport.escape_html_entities_in_json = false end @@ -60,6 +60,35 @@ class JavaScriptHelperTest < ActionView::TestCase button_to_function("Greeting") end + def test_link_to_function + assert_dom_equal %(Greeting), + link_to_function("Greeting", "alert('Hello world!')") + end + + def test_link_to_function_with_existing_onclick + assert_dom_equal %(Greeting), + link_to_function("Greeting", "alert('Hello world!')", :onclick => "confirm('Sanity!')") + end + + def test_link_to_function_with_rjs_block + html = link_to_function( "Greet me!" ) do |page| + page.replace_html 'header', "

Greetings

" + end + assert_dom_equal %(Greet me!), html + end + + def test_link_to_function_with_rjs_block_and_options + html = link_to_function( "Greet me!", :class => "updater" ) do |page| + page.replace_html 'header', "

Greetings

" + end + assert_dom_equal %(Greet me!), html + end + + def test_link_to_function_with_href + assert_dom_equal %(Greeting), + link_to_function("Greeting", "alert('Hello world!')", :href => 'http://example.com/') + end + def test_javascript_tag self.output_buffer = 'foo' -- cgit v1.2.3