Skip to content

Commit fe1bae9

Browse files
committed
Don't show empty section groups
1 parent 116ee68 commit fe1bae9

File tree

2 files changed

+30
-1
lines changed

2 files changed

+30
-1
lines changed

app/views/content_items/hmrc_manual.html.erb

+2-1
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,9 @@
1111

1212
<%= render "content_items/manuals/manual_layout" do %>
1313
<% @content_item.section_groups.each do |group| %>
14+
<% next unless group["child_sections"].present? %>
1415
<div class="subsection-collection">
1516
<%= render "content_items/manuals/hmrc_sections", group: group %>
1617
</div>
1718
<% end %>
18-
<% end %>
19+
<% end %>

test/integration/hmrc_manual_test.rb

+28
Original file line numberDiff line numberDiff line change
@@ -89,4 +89,32 @@ class HmrcManualTest < ActionDispatch::IntegrationTest
8989
end
9090
end
9191
end
92+
93+
test "does not render section groups with no sections inside" do
94+
content_item_override = {
95+
"details" => {
96+
"child_section_groups" => [
97+
{
98+
title: "Some section group title 1",
99+
child_sections: [],
100+
},
101+
{
102+
title: "Some section group title 2",
103+
child_sections: [
104+
{
105+
"section_id" => "VATGPB1000",
106+
"title" => "Introduction: contents",
107+
"description" => "",
108+
"base_path" => "/hmrc-internal-manuals/vat-government-and-public-bodies/vatgpb1000",
109+
},
110+
],
111+
},
112+
],
113+
},
114+
}
115+
116+
setup_and_visit_content_item("vat-government-public-bodies", content_item_override)
117+
assert page.has_no_text?("Some section group title 1")
118+
assert page.has_text?("Some section group title 2")
119+
end
92120
end

0 commit comments

Comments
 (0)