]> source.dussan.org Git - redmine.git/commitdiff
Simpler link syntax "#note-123" to make a link to a note of the current issue (#30829).
authorGo MAEDA <maeda@farend.jp>
Wed, 20 Mar 2019 05:15:59 +0000 (05:15 +0000)
committerGo MAEDA <maeda@farend.jp>
Wed, 20 Mar 2019 05:15:59 +0000 (05:15 +0000)
Contributed by Marius BALTEANU and Yuichi HARADA.

git-svn-id: http://svn.redmine.org/redmine/trunk@17993 e93f8b46-1217-0410-a6f0-8f06a7374b81

app/helpers/application_helper.rb
test/helpers/application_helper_test.rb

index c664fd6dbe5f71850126cae4f214ec5c0f3d1ca1..d00636d4c7d8323c8aa2ab2d895a793567fe097f 100644 (file)
@@ -963,6 +963,8 @@ module ApplicationHelper
                           :class => issue.css_classes,
                           :title => "#{issue.tracker.name}: #{issue.subject.truncate(100)} (#{issue.status.name})")
                 end
+              elsif identifier == 'note'
+                link = link_to("#note-#{comment_id}", "#note-#{comment_id}")
               end
             when 'document'
               if document = Document.visible.find_by_id(oid)
@@ -1080,7 +1082,7 @@ module ApplicationHelper
                 )
               )
               (
-                (?<identifier1>\d+)
+                (?<identifier1>((\d)+|(note)))
                 (?<comment_suffix>
                   (\#note)?
                   -(?<comment_id>\d+)
index 1ae34a9f27970ab36ef32f0ae15ad2ef3565c7bb..90422ca95cf33e861e68a42c94d1f89dfab655c6 100644 (file)
@@ -28,7 +28,7 @@ class ApplicationHelperTest < Redmine::HelperTest
            :members, :member_roles, :roles,
            :repositories, :changesets,
            :projects_trackers,
-           :trackers, :issue_statuses, :issues, :versions, :documents,
+           :trackers, :issue_statuses, :issues, :versions, :documents, :journals,
            :wikis, :wiki_pages, :wiki_contents,
            :boards, :messages, :news,
            :attachments, :enumerations,
@@ -423,6 +423,14 @@ RAW
     to_test.each { |text, result| assert_equal "<p>#{result}</p>", textilizable(text), "#{text} failed" }
   end
 
+  def test_link_to_note_within_the_same_page
+    issue = Issue.find(1)
+    assert_equal '<p><a href="#note-14">#note-14</a></p>', textilizable('#note-14', :object => issue)
+
+    journal = Journal.find(2)
+    assert_equal '<p><a href="#note-2">#note-2</a></p>', textilizable('#note-2', :object => journal)
+  end
+
   def test_user_links_with_email_as_login_name_should_not_be_parsed_textile
     with_settings :text_formatting => 'textile' do
       u = User.generate!(:login => 'jsmith@somenet.foo')