Commit b5d210c9 authored by Airat Shigapov's avatar Airat Shigapov

Render hipchat notification descriptions as HTML instead of raw markdown

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