require File.dirname(__FILE__) + '/../test/test_helper' # Test that helpers from ActionView::Helpers::JavaScriptHelper are properly # escaped. class JavascriptHelperTest < ActionView::TestCase def test_button_to_function assert_render( %(<%= button_to_function 'foo&bar', "alert('foo&bar')" %>) => %( )) end def test_escape_javascript assert_render( %(<%= escape_javascript "alert('foo&bar');" %>) => %(alert(\\'foo&bar\\');)) end def test_javascript_tag assert_render( %(<%= javascript_tag "alert('foo&bar');" %>) => %( )) end def test_link_to_function assert_render( %(<%= link_to_function 'foo&bar', "alert('foo&bar')" %>) => %( foo&bar)) end end