Methods
- #
- S
- T
-
- teardown,
- test_button_to_function,
- test_button_to_function_with_onclick,
- test_button_to_function_without_function,
- test_escape_javascript,
- test_escape_javascript_with_safebuffer,
- test_function_with_href,
- test_javascript_cdata_section,
- test_javascript_tag,
- test_javascript_tag_with_options,
- test_link_to_function,
- test_link_to_function_with_existing_onclick
- U
Attributes
| [RW] | formats | |
| [RW] | output_buffer |
Instance Public methods
_evaluate_assigns_and_ivars()
Link
setup()
Link
teardown()
Link
test_escape_javascript()
Link
# File actionpack/test/template/javascript_helper_test.rb, line 26 def test_escape_javascript assert_equal '', escape_javascript(nil) assert_equal %Q(This \\"thing\\" is really\\n netos\\'), escape_javascript(%Q(This "thing" is really\n netos')) assert_equal %Q(backslash\\\\test), escape_javascript( %Q(backslash\\test) ) assert_equal %Q(dont <\\/close> tags), escape_javascript(%Q(dont </close> tags)) if "ruby".encoding_aware? assert_equal %Q(unicode 
 newline), escape_javascript(%Q(unicode \342\200\250 newline).force_encoding('UTF-8').encode!) else assert_equal %Q(unicode 
 newline), escape_javascript(%Q(unicode \342\200\250 newline)) end assert_equal %Q(dont <\\/close> tags), j(%Q(dont </close> tags)) end
test_escape_javascript_with_safebuffer()
Link
# File actionpack/test/template/javascript_helper_test.rb, line 39 def test_escape_javascript_with_safebuffer given = %Q('quoted' "double-quoted" new-line:\n </closed>) expect = %Q(\\'quoted\\' \\"double-quoted\\" new-line:\\n <\\/closed>) assert_equal expect, escape_javascript(given) assert_equal expect, escape_javascript(ActiveSupport::SafeBuffer.new(given)) assert_instance_of String, escape_javascript(given) assert_instance_of ActiveSupport::SafeBuffer, escape_javascript(ActiveSupport::SafeBuffer.new(given)) end
test_function_with_href()
Link
# File actionpack/test/template/javascript_helper_test.rb, line 73 def test_function_with_href assert_dom_equal %Q(<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
test_javascript_cdata_section()
Link
test_javascript_tag()
Link
# File actionpack/test/template/javascript_helper_test.rb, line 78 def test_javascript_tag self.output_buffer = 'foo' assert_dom_equal "<script type=\"text/javascript\">\n//<![CDATA[\nalert('hello')\n//]]>\n</script>", javascript_tag("alert('hello')") assert_equal 'foo', output_buffer, 'javascript_tag without a block should not concat to output_buffer' end
test_javascript_tag_with_options()
Link
# File actionpack/test/template/javascript_helper_test.rb, line 87 def test_javascript_tag_with_options assert_dom_equal "<script id=\"the_js_tag\" type=\"text/javascript\">\n//<![CDATA[\nalert('hello')\n//]]>\n</script>", javascript_tag("alert('hello')", :id => "the_js_tag") end
test_link_to_function()
Link
test_link_to_function_with_existing_onclick()
Link
# File actionpack/test/template/javascript_helper_test.rb, line 68 def test_link_to_function_with_existing_onclick assert_dom_equal %Q(<a href="#" onclick="confirm('Sanity!'); alert('Hello world!'); return false;">Greeting</a>), link_to_function("Greeting", "alert('Hello world!')", :onclick => "confirm('Sanity!')") end