Skip to content

Commit

Permalink
Call Embed codes service when previewing
Browse files Browse the repository at this point in the history
This updates `govspeak_to_admin_html` to call the new service on any
generated HTML, so embed codes are transformed in the live preview.
  • Loading branch information
pezholio committed Nov 20, 2024
1 parent fb981ea commit 6feae72
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
3 changes: 2 additions & 1 deletion app/helpers/admin/admin_govspeak_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ module Admin::AdminGovspeakHelper
def govspeak_to_admin_html(govspeak, images = [], attachments = [], alternative_format_contact_email = nil)
images = prepare_images(images)
attachments = prepare_attachments(attachments, alternative_format_contact_email)
wrapped_in_govspeak_div(bare_govspeak_to_admin_html(govspeak, images, attachments))
html = ContentBlockManager::FindAndReplaceEmbedCodesService.call bare_govspeak_to_admin_html(govspeak, images, attachments)
wrapped_in_govspeak_div(html)
end

def govspeak_edition_to_admin_html(edition)
Expand Down
10 changes: 10 additions & 0 deletions test/unit/app/helpers/admin/admin_govspeak_helper_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -121,4 +121,14 @@ class Admin::AdminGovspeakHelperTest < ActionView::TestCase
assert_equivalent_html "<div class=\"govspeak\">#{contact_html}</div>", govspeak_to_admin_html(input)
end
end

test "should call the embed codes helper" do
input = "Here is some Govspeak"
expected = "Expected output"
ContentBlockManager::FindAndReplaceEmbedCodesService.expects(:call).with(
bare_govspeak_to_admin_html(input, [], []),
).returns(expected)

assert_equivalent_html "<div class=\"govspeak\">#{expected}</div>", govspeak_to_admin_html(input)
end
end

0 comments on commit 6feae72

Please sign in to comment.