Commit 38703248 authored by Sean McGivern's avatar Sean McGivern

Merge branch 'nicolasdular/fix-broadcast-message-rendering' into 'master'

Fix broadcast message rendering

See merge request gitlab-org/gitlab!27755
parents 0ff9e429 a41ff9d0
......@@ -48,7 +48,7 @@ module BroadcastMessagesHelper
def render_broadcast_message(broadcast_message)
if Feature.enabled?(:broadcast_message_placeholders)
Banzai.render_and_post_process(broadcast_message.message, {
Banzai.render_field_and_post_process(broadcast_message, :message, {
current_user: current_user,
skip_project_check: true,
broadcast_message_placeholders: true
......
......@@ -8,6 +8,10 @@ module Banzai
post_process(render(text, context), context)
end
def self.render_field_and_post_process(object, field, context = {})
post_process(render_field(object, field, context), context)
end
def self.render(text, context = {})
Renderer.render(text, context)
end
......
......@@ -68,4 +68,16 @@ describe 'Broadcast Messages' do
expect(page).to have_content "Hi #{user.name}"
end
it 'renders broadcast message with placeholders and styled links' do
create(:broadcast_message, broadcast_type: 'notification', message: "Hi {{name}} <a href='gitlab.com' style='color: purple'>click</a>")
user = create(:user)
sign_in(user)
visit root_path
expected_html = "<p>Hi #{user.name} <a href=\"gitlab.com\" style=\"color: purple\">click</a></p>"
expect(page.body).to include(expected_html)
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