BigW Consortium Gitlab

Commit 3ab461dc by Airat Shigapov Committed by blackst0ne

Render hipchat notification descriptions as HTML instead of raw markdown

parent 25447b46
......@@ -144,8 +144,7 @@ class HipchatService < Service
message = "#{user_name} #{state} #{issue_link} in #{project_link}: <b>#{title}</b>"
if description
description = format_body(description)
message << description
message << format_body(Banzai::Filter::MarkdownFilter.renderer.render(description))
end
message
......@@ -167,8 +166,7 @@ class HipchatService < Service
"#{project_link}: <b>#{title}</b>"
if description
description = format_body(description)
message << description
message << format_body(Banzai::Filter::MarkdownFilter.renderer.render(description))
end
message
......@@ -219,8 +217,7 @@ class HipchatService < Service
message << title
if note
note = format_body(note)
message << note
message << format_body(Banzai::Filter::MarkdownFilter.renderer.render(note))
end
message
......
......@@ -117,7 +117,7 @@ describe HipchatService, models: true do
end
context 'issue events' do
let(:issue) { create(:issue, title: 'Awesome issue', description: 'please fix') }
let(:issue) { create(:issue, title: 'Awesome issue', description: '**please** fix') }
let(:issue_service) { Issues::CreateService.new(project, user) }
let(:issues_sample_data) { issue_service.hook_data(issue, 'open') }
......@@ -135,12 +135,12 @@ describe HipchatService, models: true do
"<a href=\"#{obj_attr[:url]}\">issue ##{obj_attr["iid"]}</a> in " \
"<a href=\"#{project.web_url}\">#{project_name}</a>: " \
"<b>Awesome issue</b>" \
"<pre>please fix</pre>")
"<pre><p><strong>please</strong> fix</p>\n</pre>")
end
end
context 'merge request events' do
let(:merge_request) { create(:merge_request, description: 'please fix', title: 'Awesome merge request', target_project: project, source_project: project) }
let(:merge_request) { create(:merge_request, description: '**please** fix', title: 'Awesome merge request', target_project: project, source_project: project) }
let(:merge_service) { MergeRequests::CreateService.new(project, user) }
let(:merge_sample_data) { merge_service.hook_data(merge_request, 'open') }
......@@ -159,7 +159,7 @@ describe HipchatService, models: true do
"<a href=\"#{obj_attr[:url]}\">merge request !#{obj_attr["iid"]}</a> in " \
"<a href=\"#{project.web_url}\">#{project_name}</a>: " \
"<b>Awesome merge request</b>" \
"<pre>please fix</pre>")
"<pre><p><strong>please</strong> fix</p>\n</pre>")
end
end
......@@ -190,7 +190,7 @@ describe HipchatService, models: true do
"<a href=\"#{obj_attr[:url]}\">commit #{commit_id}</a> in " \
"<a href=\"#{project.web_url}\">#{project_name}</a>: " \
"#{title}" \
"<pre>a comment on a commit</pre>")
"<pre><p>a comment on a commit</p>\n</pre>")
end
end
......@@ -203,7 +203,7 @@ describe HipchatService, models: true do
let(:merge_request_note) do
create(:note_on_merge_request, noteable: merge_request,
project: project,
note: "merge request note")
note: "merge request **note**")
end
it "calls Hipchat API for merge request comment events" do
......@@ -222,7 +222,7 @@ describe HipchatService, models: true do
"<a href=\"#{obj_attr[:url]}\">merge request !#{merge_id}</a> in " \
"<a href=\"#{project.web_url}\">#{project_name}</a>: " \
"<b>#{title}</b>" \
"<pre>merge request note</pre>")
"<pre><p>merge request <strong>note</strong></p>\n</pre>")
end
end
......@@ -230,7 +230,7 @@ describe HipchatService, models: true do
let(:issue) { create(:issue, project: project) }
let(:issue_note) do
create(:note_on_issue, noteable: issue, project: project,
note: "issue note")
note: "issue **note**")
end
it "calls Hipchat API for issue comment events" do
......@@ -247,7 +247,7 @@ describe HipchatService, models: true do
"<a href=\"#{obj_attr[:url]}\">issue ##{issue_id}</a> in " \
"<a href=\"#{project.web_url}\">#{project_name}</a>: " \
"<b>#{title}</b>" \
"<pre>issue note</pre>")
"<pre><p>issue <strong>note</strong></p>\n</pre>")
end
end
......@@ -275,7 +275,7 @@ describe HipchatService, models: true do
"<a href=\"#{obj_attr[:url]}\">snippet ##{snippet_id}</a> in " \
"<a href=\"#{project.web_url}\">#{project_name}</a>: " \
"<b>#{title}</b>" \
"<pre>snippet note</pre>")
"<pre><p>snippet note</p>\n</pre>")
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