]> source.dussan.org Git - redmine.git/commitdiff
add tests of ApplicationHelper#truncate_single_line
authorToshi MARUYAMA <marutosijp2@yahoo.co.jp>
Thu, 6 Feb 2014 00:36:50 +0000 (00:36 +0000)
committerToshi MARUYAMA <marutosijp2@yahoo.co.jp>
Thu, 6 Feb 2014 00:36:50 +0000 (00:36 +0000)
git-svn-id: http://svn.redmine.org/redmine/trunk@12824 e93f8b46-1217-0410-a6f0-8f06a7374b81

test/unit/helpers/application_helper_test.rb

index 9dc9de5e70fa98279eda165ab73851b1daf49bad..965d4dda28f4c71b0a44ec6060de742c6762f56a 100644 (file)
@@ -1340,4 +1340,22 @@ RAW
   ensure
     Redmine::Utils.relative_url_root = ''
   end
+
+  def test_truncate_single_line
+    str = "01234"
+    result = truncate_single_line("#{str}\n#{str}", :length => 10)
+    assert_equal "01234 0...", result
+    assert !result.html_safe?
+    result = truncate_single_line("#{str}<&#>\n#{str}\n#{str}", :length => 15)
+    assert_equal "01234<&#> 01...", result
+    assert !result.html_safe?
+  end
+
+  def test_truncate_single_line_non_ascii
+    ja = "\xe6\x97\xa5\xe6\x9c\xac\xe8\xaa\x9e"
+    ja.force_encoding('UTF-8') if ja.respond_to?(:force_encoding)
+    result = truncate_single_line("#{ja}\n#{ja}\n#{ja}", :length => 10)
+    assert_equal "#{ja} #{ja}...", result
+    assert !result.html_safe?
+  end
 end