diff options
author | Carlos Antonio da Silva <carlosantoniodasilva@gmail.com> | 2012-09-08 05:02:18 -0700 |
---|---|---|
committer | Carlos Antonio da Silva <carlosantoniodasilva@gmail.com> | 2012-09-08 05:02:18 -0700 |
commit | bf27f6b2f711cc839b023174884c5c3fe3c6dd8d (patch) | |
tree | b61540a349528a5f908ce87a29f95b512ce9aaf0 /actionpack/test | |
parent | 63730271127f4b1540fcd469d42b46018bd13ab4 (diff) | |
parent | 963c50eca87373bed403358c076b377ad62454ef (diff) | |
download | rails-bf27f6b2f711cc839b023174884c5c3fe3c6dd8d.tar.gz rails-bf27f6b2f711cc839b023174884c5c3fe3c6dd8d.tar.bz2 rails-bf27f6b2f711cc839b023174884c5c3fe3c6dd8d.zip |
Merge pull request #7189 from GCorbel/excerpt_with_separation
Add a separator option for the excerpt function.
Diffstat (limited to 'actionpack/test')
-rw-r--r-- | actionpack/test/template/text_helper_test.rb | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/actionpack/test/template/text_helper_test.rb b/actionpack/test/template/text_helper_test.rb index c0f694b2bf..4525efe73c 100644 --- a/actionpack/test/template/text_helper_test.rb +++ b/actionpack/test/template/text_helper_test.rb @@ -303,6 +303,19 @@ class TextHelperTest < ActionView::TestCase assert_equal options, passed_options end + def test_excerpt_with_separator + options = { :separator => ' ', :radius => 1 } + assert_equal('...a very beautiful...', excerpt('This is a very beautiful morning', 'very', options)) + assert_equal('This is...', excerpt('This is a very beautiful morning', 'this', options)) + assert_equal('...beautiful morning', excerpt('This is a very beautiful morning', 'morning', options)) + + options = { :separator => "\n", :radius => 0 } + assert_equal("...very long...", excerpt("my very\nvery\nvery long\nstring", 'long', options)) + + options = { :separator => "\n", :radius => 1 } + assert_equal("...very\nvery long\nstring", excerpt("my very\nvery\nvery long\nstring", 'long', options)) + end + def test_word_wrap assert_equal("my very very\nvery long\nstring", word_wrap("my very very very long string", :line_width => 15)) end |