diff --git a/app/views/content_items/hmrc_manual.html.erb b/app/views/content_items/hmrc_manual.html.erb index d2a301ef7..d5de462e5 100644 --- a/app/views/content_items/hmrc_manual.html.erb +++ b/app/views/content_items/hmrc_manual.html.erb @@ -11,8 +11,9 @@ <%= render "content_items/manuals/manual_layout" do %> <% @content_item.section_groups.each do |group| %> + <% next unless group["child_sections"].present? %>
<%= render "content_items/manuals/hmrc_sections", group: group %>
<% end %> -<% end %> \ No newline at end of file +<% end %> diff --git a/test/integration/hmrc_manual_test.rb b/test/integration/hmrc_manual_test.rb index 57ecbd319..23ee42697 100644 --- a/test/integration/hmrc_manual_test.rb +++ b/test/integration/hmrc_manual_test.rb @@ -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