aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/test/template
diff options
context:
space:
mode:
authorCarlos Antonio da Silva <carlosantoniodasilva@gmail.com>2012-01-12 21:04:02 -0200
committerCarlos Antonio da Silva <carlosantoniodasilva@gmail.com>2012-02-01 08:55:18 -0200
commit608eddc6f5465c642bd02f5523a8e486a87020b1 (patch)
tree0f380e43d5db671ecb0bd58248d90452cf411a3d /actionpack/test/template
parent0eb46736978eea4f37f64270d1185a1228198b6c (diff)
downloadrails-608eddc6f5465c642bd02f5523a8e486a87020b1.tar.gz
rails-608eddc6f5465c642bd02f5523a8e486a87020b1.tar.bz2
rails-608eddc6f5465c642bd02f5523a8e486a87020b1.zip
Move escape_once logic to ERB::Util, where it belongs to
All the logic is based on the HTML_ESCAPE constant available in ERB::Util, so it seems more logic to have the entire method there and just delegate the helper to use it.
Diffstat (limited to 'actionpack/test/template')
-rw-r--r--actionpack/test/template/erb_util_test.rb14
1 files changed, 14 insertions, 0 deletions
diff --git a/actionpack/test/template/erb_util_test.rb b/actionpack/test/template/erb_util_test.rb
index eba2ef64e0..ca2710e9b3 100644
--- a/actionpack/test/template/erb_util_test.rb
+++ b/actionpack/test/template/erb_util_test.rb
@@ -44,4 +44,18 @@ class ErbUtilTest < ActiveSupport::TestCase
assert_equal chr, html_escape(chr)
end
end
+
+ def test_html_escape_once
+ assert_equal '1 &lt; 2 &amp; 3', html_escape_once('1 < 2 &amp; 3')
+ end
+
+ def test_html_escape_once_returns_unsafe_strings_when_passed_unsafe_strings
+ value = html_escape_once('1 < 2 &amp; 3')
+ assert !value.html_safe?
+ end
+
+ def test_html_escape_once_returns_safe_strings_when_passed_safe_strings
+ value = html_escape_once('1 < 2 &amp; 3'.html_safe)
+ assert value.html_safe?
+ end
end