From 2d189f4bfcc16b2eb1440b1f40741b0aed2db105 Mon Sep 17 00:00:00 2001 From: Dilwoar Hussain Date: Tue, 25 Sep 2018 10:58:47 +0100 Subject: [PATCH] Used combined list for also_part_of_step_nav function This is so that the also part of step navs also shows when a step by step is actively being used. --- .../page_with_step_by_step_navigation.rb | 3 ++- .../page_with_step_by_step_navigation_spec.rb | 24 +++++++++++++++++++ 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/lib/govuk_publishing_components/presenters/page_with_step_by_step_navigation.rb b/lib/govuk_publishing_components/presenters/page_with_step_by_step_navigation.rb index fcc5f63e0c..f996668ce1 100644 --- a/lib/govuk_publishing_components/presenters/page_with_step_by_step_navigation.rb +++ b/lib/govuk_publishing_components/presenters/page_with_step_by_step_navigation.rb @@ -44,7 +44,8 @@ def related_links end def also_part_of_step_nav - step_by_step_navs = step_navs.delete_if { |step_nav| step_nav.content_id == active_step_by_step.content_id } + step_navs_list = step_navs_combined_list + step_by_step_navs = step_navs_list.delete_if { |step_nav| step_nav.content_id == active_step_by_step.content_id } format_related_links(step_by_step_navs) end diff --git a/spec/lib/presenters/page_with_step_by_step_navigation_spec.rb b/spec/lib/presenters/page_with_step_by_step_navigation_spec.rb index 570a7d95c0..f16bf8415e 100644 --- a/spec/lib/presenters/page_with_step_by_step_navigation_spec.rb +++ b/spec/lib/presenters/page_with_step_by_step_navigation_spec.rb @@ -399,6 +399,30 @@ expect(step_nav_helper.active_step_by_step?).to eq(true) expect(step_nav_helper.show_header?).to eq(true) end + + it "shows the titles of the other step navs the content item is part of" do + step_nav = { + "content_id" => "cccc-dddd", + "title" => "Learn to spacewalk: small step by giant leap", + "base_path" => "/learn-to-spacewalk" + } + another_step_nav = { + "content_id" => "aaaa-bbbb", + "title" => "Lose your lunch: lurch by lurch", + "base_path" => "/lose-your-lunch" + } + content_item_in_two_step_navs = { + "title" => "Book a session in the vomit comet", + "document_type" => "transaction", + "links" => { + "related_to_step_navs" => [step_nav, another_step_nav], + } + } + step_nav_helper = described_class.new(content_item_in_two_step_navs, "/driving-lessons-learning-to-drive", "step-by-step-nav" => "cccc-dddd") + expect(step_nav_helper.also_part_of_step_nav.count).to eq(1) + expect(step_nav_helper.also_part_of_step_nav.first[:tracking_id]).to eq('aaaa-bbbb') + expect(step_nav_helper.show_also_part_of_step_nav?).to be true + end end def payload_for(schema, content_item)