Methods
#
S
T
U
Attributes
[RW] formats
[RW] output_buffer
Instance Public methods
_evaluate_assigns_and_ivars()
# File actionpack/test/template/javascript_helper_test.rb, line 7
def _evaluate_assigns_and_ivars() end
setup()
# File actionpack/test/template/javascript_helper_test.rb, line 16
def setup
  super
  ActiveSupport.escape_html_entities_in_json  = true
  @template = self
end
teardown()
# File actionpack/test/template/javascript_helper_test.rb, line 22
def teardown
  ActiveSupport.escape_html_entities_in_json  = false
end
test_button_to_function()
# File actionpack/test/template/javascript_helper_test.rb, line 48
def test_button_to_function
  assert_dom_equal %Q(<input type="button" onclick="alert(&#x27;Hello world!&#x27;);" value="Greeting" />),
    button_to_function("Greeting", "alert('Hello world!')")
end
test_button_to_function_with_onclick()
# File actionpack/test/template/javascript_helper_test.rb, line 53
def test_button_to_function_with_onclick
  assert_dom_equal "<input onclick=\"alert(&#x27;Goodbye World :(&#x27;); alert(&#x27;Hello world!&#x27;);\" type=\"button\" value=\"Greeting\" />",
    button_to_function("Greeting", "alert('Hello world!')", :onclick => "alert('Goodbye World :(')")
end
test_button_to_function_without_function()
# File actionpack/test/template/javascript_helper_test.rb, line 58
def test_button_to_function_without_function
  assert_dom_equal "<input onclick=\";\" type=\"button\" value=\"Greeting\" />",
    button_to_function("Greeting")
end
test_escape_javascript()
# 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 &#x2028; newline), escape_javascript(%Q(unicode \342\200\250 newline).force_encoding('UTF-8').encode!)
  else
    assert_equal %Q(unicode &#x2028; 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()
# 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()
# 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(&#x27;Hello world!&#x27;); return false;">Greeting</a>),
    link_to_function("Greeting", "alert('Hello world!')", :href => 'http://example.com/')
end
test_javascript_cdata_section()
# File actionpack/test/template/javascript_helper_test.rb, line 92
def test_javascript_cdata_section
  assert_dom_equal "\n//<![CDATA[\nalert('hello')\n//]]>\n", javascript_cdata_section("alert('hello')")
end
test_javascript_tag()
# 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()
# 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
update_details(details)
# File actionpack/test/template/javascript_helper_test.rb, line 11
def update_details(details)
  @details = details
  yield if block_given?
end