Skip to content

Commit

Permalink
Merge pull request #3267 from alphagov/2681-hmrc-manuals-do-not-show-…
Browse files Browse the repository at this point in the history
…the-title-of-a-section-group-if-its-empty-s-m

HMRC Manuals: Do not show the title of a section group if the group is empty
  • Loading branch information
unoduetre authored Jul 16, 2024
2 parents 01792f3 + fe1bae9 commit a6f2a6d
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 1 deletion.
3 changes: 2 additions & 1 deletion app/views/content_items/hmrc_manual.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@

<%= render "content_items/manuals/manual_layout" do %>
<% @content_item.section_groups.each do |group| %>
<% next unless group["child_sections"].present? %>
<div class="subsection-collection">
<%= render "content_items/manuals/hmrc_sections", group: group %>
</div>
<% end %>
<% end %>
<% end %>
28 changes: 28 additions & 0 deletions test/integration/hmrc_manual_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -89,4 +89,32 @@ class HmrcManualTest < ActionDispatch::IntegrationTest
end
end
end

test "does not render section groups with no sections inside" do
content_item_override = {
"details" => {
"child_section_groups" => [
{
title: "Some section group title 1",
child_sections: [],
},
{
title: "Some section group title 2",
child_sections: [
{
"section_id" => "VATGPB1000",
"title" => "Introduction: contents",
"description" => "",
"base_path" => "/hmrc-internal-manuals/vat-government-and-public-bodies/vatgpb1000",
},
],
},
],
},
}

setup_and_visit_content_item("vat-government-public-bodies", content_item_override)
assert page.has_no_text?("Some section group title 1")
assert page.has_text?("Some section group title 2")
end
end

0 comments on commit a6f2a6d

Please sign in to comment.