diff options
author | Jeremy Kemper <jeremy@bitsweat.net> | 2006-11-19 09:57:16 +0000 |
---|---|---|
committer | Jeremy Kemper <jeremy@bitsweat.net> | 2006-11-19 09:57:16 +0000 |
commit | 229ea6537459d9d55c2f140bce14fdfe45b4472e (patch) | |
tree | f1ba482e49a8af3eed24a39c855bb5cb54b33d87 /actionpack/test | |
parent | bc76044fde8701d19ab85d244789a69ba5ed9bbd (diff) | |
download | rails-229ea6537459d9d55c2f140bce14fdfe45b4472e.tar.gz rails-229ea6537459d9d55c2f140bce14fdfe45b4472e.tar.bz2 rails-229ea6537459d9d55c2f140bce14fdfe45b4472e.zip |
simple_format helper doesn't choke on nil. Closes #6644.
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@5561 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'actionpack/test')
-rw-r--r-- | actionpack/test/template/text_helper_test.rb | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/actionpack/test/template/text_helper_test.rb b/actionpack/test/template/text_helper_test.rb index 43538dd9b1..8825a24f14 100644 --- a/actionpack/test/template/text_helper_test.rb +++ b/actionpack/test/template/text_helper_test.rb @@ -11,17 +11,21 @@ class TextHelperTest < Test::Unit::TestCase # a view is rendered. The cycle helper depends on this behavior. @_cycles = nil if (defined? @_cycles) end - + def test_simple_format + assert_equal "<p></p>", simple_format(nil) + assert_equal "<p>crazy\n<br /> cross\n<br /> platform linebreaks</p>", simple_format("crazy\r\n cross\r platform linebreaks") assert_equal "<p>A paragraph</p>\n\n<p>and another one!</p>", simple_format("A paragraph\n\nand another one!") assert_equal "<p>A paragraph\n<br /> With a newline</p>", simple_format("A paragraph\n With a newline") - - text = "A\nB\nC\nD" + + text = "A\nB\nC\nD".freeze assert_equal "<p>A\n<br />B\n<br />C\n<br />D</p>", simple_format(text) - assert_equal text, "A\nB\nC\nD" + + text = "A\r\n \nB\n\n\r\n\t\nC\nD".freeze + assert_equal "<p>A\n<br /> \n<br />B</p>\n\n<p>\t\n<br />C\n<br />D</p>", simple_format(text) end - + def test_truncate assert_equal "Hello World!", truncate("Hello World!", 12) assert_equal "Hello Wor...", truncate("Hello World!!", 12) |