aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/test/template/javascript_helper_test.rb
diff options
context:
space:
mode:
authorwycats <wycats@gmail.com>2010-03-26 15:10:24 -0700
committerwycats <wycats@gmail.com>2010-03-26 15:10:24 -0700
commit197904341f2b2f21d69c653cede3aec124e86720 (patch)
tree83f1234e238016126860a929594db22e1862d783 /actionpack/test/template/javascript_helper_test.rb
parent76d2c455c0607b4cd5f238cadef8f933a18567fb (diff)
parentb3a0aed028835ce4551c4a76742744a40a71b0be (diff)
downloadrails-197904341f2b2f21d69c653cede3aec124e86720.tar.gz
rails-197904341f2b2f21d69c653cede3aec124e86720.tar.bz2
rails-197904341f2b2f21d69c653cede3aec124e86720.zip
Merge branch 'master' into docrails
Diffstat (limited to 'actionpack/test/template/javascript_helper_test.rb')
-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'