Skip to content

Commit 70f902a

Browse files
committed
Display breadcrumbs if they are present
A bug was introduced in 8128fb2 so that breadcrumbs were no longer being displayed on the page. If breadcrumbs are present in the content item, we should display them. If they're absent, display a back link to the parent manual.
1 parent 6ab51a2 commit 70f902a

File tree

2 files changed

+34
-5
lines changed

2 files changed

+34
-5
lines changed

app/views/content_items/manuals/_manual_section_layout.html.erb

+11-4
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,17 @@
11
<% show_contents ||= false %>
22

33
<% content_for :main do %>
4-
<%= render "govuk_publishing_components/components/back_link", {
5-
text: t("manuals.breadcrumb_contents"),
6-
href: @content_item.base_path
7-
} %>
4+
<% if @content_item.breadcrumbs.any? %>
5+
<%= render "govuk_publishing_components/components/breadcrumbs", {
6+
border: "bottom",
7+
breadcrumbs: @content_item.breadcrumbs,
8+
collapse_on_mobile: false } %>
9+
<% else %>
10+
<%= render "govuk_publishing_components/components/back_link", {
11+
text: t("manuals.breadcrumb_contents"),
12+
href: @content_item.base_path
13+
} %>
14+
<% end %>
815
<div id="manuals-frontend" class="manuals-frontend-body">
916
<% if show_contents %>
1017
<%= render "govuk_publishing_components/components/contents_list", {

test/integration/hmrc_manual_section_test.rb

+23-1
Original file line numberDiff line numberDiff line change
@@ -42,12 +42,18 @@ class HmrcManualSectionTest < ActionDispatch::IntegrationTest
4242
end
4343
end
4444

45-
test "renders back link" do
45+
test "renders back link if breadcrumbs are not set" do
4646
setup_and_visit_manual_section
4747

4848
assert page.has_link?(I18n.t("manuals.breadcrumb_contents"), href: "/hmrc-internal-manuals/vat-government-and-public-bodies")
4949
end
5050

51+
test "renders breadcrumbs if they are set in the content item" do
52+
setup_and_visit_manual_section_with_breadcrumbs
53+
54+
assert page.has_link?("DMBM510000", href: "/hmrc-internal-manuals/debt-management-and-banking/dmbm510000")
55+
end
56+
5157
test "renders section group" do
5258
setup_and_visit_manual_section
5359

@@ -92,4 +98,20 @@ def setup_and_visit_manual_section(content_item = get_content_example("vatgpb200
9298
stub_content_store_has_item(@content_item["base_path"], @content_item.to_json)
9399
visit_with_cachebust((@content_item["base_path"]).to_s)
94100
end
101+
102+
def setup_and_visit_manual_section_with_breadcrumbs(content_item = get_content_example("vatgpb2000"))
103+
@manual = get_content_example_by_schema_and_name("hmrc_manual", "vat-government-public-bodies")
104+
@content_item = content_item
105+
first_crumb = { "base_path" => "/hmrc-internal-manuals/debt-management-and-banking/dmbm510000", "section_id" => "DMBM510000" }
106+
last_crumb = { "base_path" => "/hmrc-internal-manuals/vat-government-public-bodiesg/dmbm510100", "section_id" => "DMBM510100" }
107+
108+
@content_item["details"]["breadcrumbs"].push(first_crumb, last_crumb)
109+
manual_base_path = @content_item["details"]["manual"]["base_path"]
110+
111+
stub_content_store_has_item(manual_base_path, @manual.to_json)
112+
113+
stub_content_store_has_item(@content_item["base_path"], @content_item.to_json)
114+
stub_content_store_has_item(@content_item["details"]["breadcrumbs"].last["base_path"], @content_item.to_json)
115+
visit_with_cachebust((@content_item["base_path"]).to_s)
116+
end
95117
end

0 commit comments

Comments
 (0)