diff options
author | Airat Shigapov <contact@airatshigapov.com> | 2016-09-15 18:45:22 +0300 |
---|---|---|
committer | Airat Shigapov <contact@airatshigapov.com> | 2016-10-20 15:44:34 +0300 |
commit | b5d210c9d6d44fc664b006567b8f488e198ad04f (patch) | |
tree | 0bcf07455305ae23376634d70bd2eefe02ed5612 | |
parent | 8e218edbddd9a6fda34543e1f1ee39e44772c369 (diff) | |
download | gitlab-ce-b5d210c9d6d44fc664b006567b8f488e198ad04f.tar.gz |
Render hipchat notification descriptions as HTML instead of raw markdown
-rw-r--r-- | app/models/project_services/hipchat_service.rb | 9 | ||||
-rw-r--r-- | spec/models/project_services/hipchat_service_spec.rb | 20 |
2 files changed, 13 insertions, 16 deletions
diff --git a/app/models/project_services/hipchat_service.rb b/app/models/project_services/hipchat_service.rb index afebd3b6a12..98f0312d84e 100644 --- a/app/models/project_services/hipchat_service.rb +++ b/app/models/project_services/hipchat_service.rb @@ -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 diff --git a/spec/models/project_services/hipchat_service_spec.rb b/spec/models/project_services/hipchat_service_spec.rb index 26dd95bdfec..90066f01f6f 100644 --- a/spec/models/project_services/hipchat_service_spec.rb +++ b/spec/models/project_services/hipchat_service_spec.rb @@ -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 |