]> source.dussan.org Git - redmine.git/commitdiff
add tests of ApplicationHelper#link_to_issue subject and title
authorToshi MARUYAMA <marutosijp2@yahoo.co.jp>
Thu, 6 Feb 2014 02:38:37 +0000 (02:38 +0000)
committerToshi MARUYAMA <marutosijp2@yahoo.co.jp>
Thu, 6 Feb 2014 02:38:37 +0000 (02:38 +0000)
git-svn-id: http://svn.redmine.org/redmine/trunk@12829 e93f8b46-1217-0410-a6f0-8f06a7374b81

test/unit/helpers/application_helper_test.rb

index e640de0c72807e7d39599a0f98234e262e016842..596bfd7fbbb18e65555ade600a85d6a1a419fbee 100644 (file)
@@ -436,6 +436,41 @@ RAW
     end
   end
 
+  def test_link_to_issue_subject
+    issue = Issue.generate!(:subject => "01234567890123456789")
+    str = link_to_issue(issue, :truncate => 10)
+    result = link_to("Bug ##{issue.id}", "/issues/#{issue.id}", :class => issue.css_classes)
+    assert_equal "#{result}: 0123456...", str
+
+    issue = Issue.generate!(:subject => "<&>")
+    str = link_to_issue(issue)
+    result = link_to("Bug ##{issue.id}", "/issues/#{issue.id}", :class => issue.css_classes)
+    assert_equal "#{result}: &lt;&amp;&gt;", str
+
+    issue = Issue.generate!(:subject => "<&>0123456789012345")
+    str = link_to_issue(issue, :truncate => 10)
+    result = link_to("Bug ##{issue.id}", "/issues/#{issue.id}", :class => issue.css_classes)
+    assert_equal "#{result}: &lt;&amp;&gt;0123...", str
+  end
+
+  def test_link_to_issue_title
+    long_str = "0123456789" * 5
+
+    issue = Issue.generate!(:subject => "#{long_str}01234567890123456789")
+    str = link_to_issue(issue, :subject => false)
+    result = link_to("Bug ##{issue.id}", "/issues/#{issue.id}",
+                     :class => issue.css_classes,
+                     :title => "#{long_str}0123456...")
+    assert_equal result, str
+
+    issue = Issue.generate!(:subject => "<&>#{long_str}01234567890123456789")
+    str = link_to_issue(issue, :subject => false)
+    result = link_to("Bug ##{issue.id}", "/issues/#{issue.id}",
+                     :class => issue.css_classes,
+                     :title => "<&>#{long_str}0123...")
+    assert_equal result, str
+  end
+
   def test_multiple_repositories_redmine_links
     svn = Repository::Subversion.create!(:project_id => 1, :identifier => 'svn_repo-1', :url => 'file:///foo/hg')
     Changeset.create!(:repository => svn, :committed_on => Time.now, :revision => '123')