aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/test/template
diff options
context:
space:
mode:
authorJoshua Peek <josh@joshpeek.com>2010-03-16 22:06:16 -0500
committerJoshua Peek <josh@joshpeek.com>2010-03-16 22:06:16 -0500
commitd69e5616e821afc40efa5936c5ab6e087eb4e0c6 (patch)
treea58b6f561bc6698c7a775466d6bb39baf021ddf9 /actionpack/test/template
parent55aac2c6969e4f5209ba786120f1d7b57c80b9a0 (diff)
downloadrails-d69e5616e821afc40efa5936c5ab6e087eb4e0c6.tar.gz
rails-d69e5616e821afc40efa5936c5ab6e087eb4e0c6.tar.bz2
rails-d69e5616e821afc40efa5936c5ab6e087eb4e0c6.zip
link_to_function is here to stay
Diffstat (limited to 'actionpack/test/template')
-rw-r--r--actionpack/test/template/javascript_helper_test.rb31
1 files changed, 30 insertions, 1 deletions
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 %(<a href="#" onclick="alert('Hello world!'); return false;">Greeting</a>),
+ link_to_function("Greeting", "alert('Hello world!')")
+ end
+
+ def test_link_to_function_with_existing_onclick
+ assert_dom_equal %(<a href="#" onclick="confirm('Sanity!'); alert('Hello world!'); return false;">Greeting</a>),
+ 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', "<h1>Greetings</h1>"
+ end
+ assert_dom_equal %(<a href="#" onclick="Element.update(&quot;header&quot;, &quot;\\u003Ch1\\u003EGreetings\\u003C/h1\\u003E&quot;);; return false;">Greet me!</a>), 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', "<h1>Greetings</h1>"
+ end
+ assert_dom_equal %(<a href="#" class="updater" onclick="Element.update(&quot;header&quot;, &quot;\\u003Ch1\\u003EGreetings\\u003C/h1\\u003E&quot;);; return false;">Greet me!</a>), html
+ end
+
+ def test_link_to_function_with_href
+ assert_dom_equal %(<a href="http://example.com/" onclick="alert('Hello world!'); return false;">Greeting</a>),
+ link_to_function("Greeting", "alert('Hello world!')", :href => 'http://example.com/')
+ end
+
def test_javascript_tag
self.output_buffer = 'foo'