Project

General

Profile

Feature #30829 » 30829-linkto-current-issue-note.patch

Yuichi HARADA, 2019-03-04 07:52

View differences:

app/helpers/application_helper.rb
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
$&
......
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 == '##'
......
)
)
(
(?<identifier1>\d+)
(?<comment_suffix>
(\#note)?
-(?<comment_id>\d+)
)?
(
(?<identifier1>\d+)
(?<comment_suffix1>
(\#note)?
-(?<comment_id1>\d+)
)?
)|
(
(?<comment_suffix2>
note\-(?<comment_id2>\d+)
)
)
)|
(
(?<sep3>:)
test/helpers/application_helper_test.rb
: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,
......
to_test.each { |text, result| assert_equal "<p>#{result}</p>", 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 "<p>#{result}</p>", 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 "<p>#{result}</p>", 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')
(1-1/2)