From f292f0971f4d3f02ca2aba4aef46666c27199a40 Mon Sep 17 00:00:00 2001 From: Tadas Tamosauskas Date: Mon, 20 Jun 2011 14:51:07 +0100 Subject: Do not change a frozen text passed to simple_format text helper --- actionpack/test/template/text_helper_test.rb | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'actionpack/test/template/text_helper_test.rb') diff --git a/actionpack/test/template/text_helper_test.rb b/actionpack/test/template/text_helper_test.rb index 5a43b5f864..f7c3986bb1 100644 --- a/actionpack/test/template/text_helper_test.rb +++ b/actionpack/test/template/text_helper_test.rb @@ -36,8 +36,8 @@ class TextHelperTest < ActionView::TestCase text = "A\r\n \nB\n\n\r\n\t\nC\nD".freeze assert_equal "

A\n
\n
B

\n\n

\t\n
C\n
D

", simple_format(text) - assert_equal %q(

This is a classy test

), simple_format("This is a classy test", :class => 'test') - assert_equal %Q(

para 1

\n\n

para 2

), simple_format("para 1\n\npara 2", :class => 'test') + assert_equal %q(

This is a classy test

), simple_format("This is a classy test", :class => 'test') + assert_equal %Q(

para 1

\n\n

para 2

), simple_format("para 1\n\npara 2", :class => 'test') end def test_simple_format_should_sanitize_input_when_sanitize_option_is_not_false @@ -48,6 +48,13 @@ class TextHelperTest < ActionView::TestCase assert_equal "

test with unsafe string

", simple_format(" test with unsafe string ", {}, :sanitize => false) end + def test_simple_format_should_not_change_the_frozen_text_passed + text = "Ok" + text_clone = text.dup + simple_format(text.freeze) + assert_equal text_clone, text + end + def test_truncate_should_not_be_html_safe assert !truncate("Hello World!", :length => 12).html_safe? end -- cgit v1.2.3