diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 8fa56ac55..d7b51f4f3 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -897,8 +897,8 @@ module ApplicationHelper repo_identifier = $~[:repo_identifier] sep = $~[:sep1] || $~[:sep2] || $~[:sep3] || $~[:sep4] identifier = $~[:identifier1] || $~[:identifier2] || $~[:identifier3] - comment_suffix = $~[:comment_suffix] - comment_id = $~[:comment_id] + comment_suffix = $~[:comment_suffix1] || $~[:comment_suffix2] + comment_id = $~[:comment_id1] || $~[:comment_id2] if tag_content $& @@ -934,8 +934,22 @@ module ApplicationHelper oid = identifier.to_i case prefix when nil - if oid.to_s == identifier && + issue = nil + if oid.to_s == identifier issue = Issue.visible.find_by_id(oid) + elsif identifier.blank? + oid = nil + issue = + case obj + when Issue + obj + when Journal + obj.issue + else + nil + end + end + if issue anchor = comment_id ? "note-#{comment_id}" : nil url = issue_url(issue, :only_path => only_path, :anchor => anchor) link = if sep == '##' @@ -1066,11 +1080,18 @@ module ApplicationHelper ) ) ( - (?\d+) - (? - (\#note)? - -(?\d+) - )? + ( + (?\d+) + (? + (\#note)? + -(?\d+) + )? + )| + ( + (? + note\-(?\d+) + ) + ) )| ( (?:) diff --git a/test/helpers/application_helper_test.rb b/test/helpers/application_helper_test.rb index bfefc1052..c44631326 100644 --- a/test/helpers/application_helper_test.rb +++ b/test/helpers/application_helper_test.rb @@ -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,33 @@ RAW to_test.each { |text, result| assert_equal "

#{result}

", textilizable(text), "#{text} failed" } end + def test_issue_links_with_note_id_only + issue = Issue.find(1) + css_classes = issue.css_classes + @project = issue.project + + to_test = { + '#note-14' => + link_to('#note-14', {:controller => 'issues', :action => 'show', :id => 1, :anchor => 'note-14'}, + :class => css_classes, :title => 'Bug: Cannot print recipes (New)' + ), + } + to_test.each do |text, result| + assert_equal "

#{result}

", textilizable(text, :object => issue), "#{text} failed" + end + + journal = Journal.find(2) # #1#note-2 + to_test = { + '#note-2' => + link_to('#note-2', {:controller => 'issues', :action => 'show', :id => 1, :anchor => 'note-2'}, + :class => css_classes, :title => 'Bug: Cannot print recipes (New)' + ), + } + to_test.each do |text, result| + assert_equal "

#{result}

", textilizable(text, :object => journal), "#{text} failed" + end + 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')