aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/test/template
diff options
context:
space:
mode:
authorPaul Gallagher <gallagher.paul@gmail.com>2011-06-08 22:46:15 +0800
committerPrem Sichanugrist <s@sikachu.com>2011-06-08 11:05:15 -0400
commitbf2f039a93d1b5bacffcda14e2c58f39dfcf7fd4 (patch)
treede7ae76bcec782d718627aa03e8a0962fd244875 /actionpack/test/template
parentb64524d6fdacdd03277efd7b12ff0e8fa97737e2 (diff)
downloadrails-bf2f039a93d1b5bacffcda14e2c58f39dfcf7fd4.tar.gz
rails-bf2f039a93d1b5bacffcda14e2c58f39dfcf7fd4.tar.bz2
rails-bf2f039a93d1b5bacffcda14e2c58f39dfcf7fd4.zip
Make escape_javascript happy to handle SafeBuffers
* see GH#1553 * allow for the fact that gsub on SafeBuffer does not pass match variables $1, $2 etc to a block
Diffstat (limited to 'actionpack/test/template')
-rw-r--r--actionpack/test/template/javascript_helper_test.rb7
1 files changed, 7 insertions, 0 deletions
diff --git a/actionpack/test/template/javascript_helper_test.rb b/actionpack/test/template/javascript_helper_test.rb
index 538e0e9874..15bd6b4c47 100644
--- a/actionpack/test/template/javascript_helper_test.rb
+++ b/actionpack/test/template/javascript_helper_test.rb
@@ -30,6 +30,13 @@ class JavaScriptHelperTest < ActionView::TestCase
assert_equal %(dont <\\/close> tags), j(%(dont </close> tags))
end
+ def test_escape_javascript_with_safebuffer
+ given = %('quoted' "double-quoted" new-line:\n </closed>)
+ expect = %(\\'quoted\\' \\"double-quoted\\" new-line:\\n <\\/closed>)
+ assert_equal expect, escape_javascript(given)
+ assert_equal expect, escape_javascript(ActiveSupport::SafeBuffer.new(given))
+ end
+
def test_button_to_function
assert_dom_equal %(<input type="button" onclick="alert('Hello world!');" value="Greeting" />),
button_to_function("Greeting", "alert('Hello world!')")