Commit cd79efbc authored by Heinrich Lee Yu's avatar Heinrich Lee Yu

Merge branch 'fix_sdesk_links' into 'master'

Fix rendering of service desk notes

See merge request gitlab-org/gitlab!45772
parents 1bc00204 28dea01b
......@@ -58,10 +58,12 @@ module Emails
def template_content(email_type)
template = Gitlab::Template::ServiceDeskTemplate.find(email_type, @project)
text = substitute_template_replacements(template.content)
markdown(text, project: @project)
context = { project: @project, pipeline: :email }
context[:author] = @note.author if email_type == 'new_note'
markdown(text, context)
rescue Gitlab::Template::Finders::RepoTemplateFinder::FileNotFoundError
nil
end
......
---
title: Render correct URLs for uploads in service desk issues when custom template
is used.
merge_request: 45772
author:
type: fixed
......@@ -183,6 +183,25 @@ RSpec.describe Emails::ServiceDesk do
it_behaves_like 'handle template content', 'new_note'
end
context 'with upload link in the note' do
let_it_be(:upload_path) { '/uploads/e90decf88d8f96fe9e1389afc2e4a91f/test.jpg' }
let_it_be(:note) { create(:note_on_issue, noteable: issue, project: project, note: "a new comment with [file](#{upload_path})") }
let(:template_content) { 'some text %{ NOTE_TEXT }' }
let(:expected_body) { %Q(some text a new comment with <a href="#{project.web_url}#{upload_path}" data-link="true" class="gfm">file</a>) }
it_behaves_like 'handle template content', 'new_note'
end
context 'with all-user reference in a an external author comment' do
let_it_be(:note) { create(:note_on_issue, noteable: issue, project: project, note: "Hey @all, just a ping", author: User.support_bot) }
let(:template_content) { 'some text %{ NOTE_TEXT }' }
let(:expected_body) { 'Hey , just a ping' }
it_behaves_like 'handle template content', 'new_note'
end
end
end
end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment