Skip to content

Commit

Permalink
Add content block guidance in the sidebar
Browse files Browse the repository at this point in the history
This is only added to the resulting HTML if the feature flag is set.
  • Loading branch information
pezholio committed Nov 28, 2024
1 parent ed6c701 commit 704dc45
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 0 deletions.
1 change: 1 addition & 0 deletions app/helpers/admin/sidebar_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ def simple_formatting_sidebar(options = {})
sidebar_content = []
sidebar_content << render("admin/editions/govspeak_help", options)
sidebar_content << render("admin/editions/style_guidance", options)
sidebar_content << render("admin/editions/content_block_guidance", options) if Flipflop.show_link_to_content_block_manager?
raw sidebar_content.join("\n")
end
end
6 changes: 6 additions & 0 deletions app/views/admin/editions/_content_block_guidance.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<h3 class="govuk-heading-m">Content block</h3>

<p class="govuk-body">
To create, edit and use standardised content, go to the
<%= link_to "Content Block Manager (opens in new tab)", content_block_manager.content_block_manager_root_path, class: "govuk-link", target: "_blank", rel: "noopener" %>.
</p>
32 changes: 32 additions & 0 deletions test/unit/app/helpers/admin/sidebar_helper_test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
require "test_helper"

class Admin::SidebarHelperTest < ActionView::TestCase
extend Minitest::Spec::DSL

before do
test_strategy = Flipflop::FeatureSet.current.test!
test_strategy.switch!(:show_link_to_content_block_manager, content_block_enabled)
end

context "when #show_link_to_content_block_manager? is false" do
let(:content_block_enabled) { false }

it "does not include content block guidance" do
result = simple_formatting_sidebar
assert_includes result, "Formatting"
assert_includes result, "Use plain English"
assert_not_includes result, "Content block"
end
end

context "when #show_link_to_content_block_manager? is true" do
let(:content_block_enabled) { true }

it "includes content block guidance" do
result = simple_formatting_sidebar
assert_includes result, "Formatting"
assert_includes result, "Use plain English"
assert_includes result, "Content block"
end
end
end

0 comments on commit 704dc45

Please sign in to comment.