aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/test/safe_buffer_test.rb
diff options
context:
space:
mode:
authorYumin Wong <itsbagpack@github.com>2018-08-31 11:46:09 -0500
committerYumin Wong <itsbagpack@github.com>2018-08-31 11:46:09 -0500
commit3f5bd11ed651cef4f098c1d9dba16fe099e89a42 (patch)
treeedc966cc45c39996765a31f5da71a80d65c39221 /activesupport/test/safe_buffer_test.rb
parent12fadea8aee3981654149d6e8ff5099bca31c679 (diff)
downloadrails-3f5bd11ed651cef4f098c1d9dba16fe099e89a42.tar.gz
rails-3f5bd11ed651cef4f098c1d9dba16fe099e89a42.tar.bz2
rails-3f5bd11ed651cef4f098c1d9dba16fe099e89a42.zip
SafeBuffer should maintain safety upon getting a slice via a range if original buffer was safe.
Co-Authored-By: no-itsbackpack <no-itsbackpack@github.com>
Diffstat (limited to 'activesupport/test/safe_buffer_test.rb')
-rw-r--r--activesupport/test/safe_buffer_test.rb12
1 files changed, 12 insertions, 0 deletions
diff --git a/activesupport/test/safe_buffer_test.rb b/activesupport/test/safe_buffer_test.rb
index 9456bb8753..bf661a5f92 100644
--- a/activesupport/test/safe_buffer_test.rb
+++ b/activesupport/test/safe_buffer_test.rb
@@ -150,6 +150,18 @@ class SafeBufferTest < ActiveSupport::TestCase
assert_not y.html_safe?, "should not be safe"
end
+ test "Should continue safe on slice" do
+ x = "<div>foo</div>".html_safe
+
+ assert x.html_safe?, "should be safe"
+
+ # getting a slice of it
+ y = x[0..-1]
+
+ # should still be safe
+ assert y.html_safe?, "should be safe"
+ end
+
test "Should work with interpolation (array argument)" do
x = "foo %s bar".html_safe % ["qux"]
assert_equal "foo qux bar", x