Skip to content

Commit

Permalink
Used combined list for also_part_of_step_nav function
Browse files Browse the repository at this point in the history
This is so that the also part of step navs also shows when a step by step
is actively being used.
  • Loading branch information
Dilwoar Hussain committed Sep 25, 2018
1 parent dd62c7a commit 2d189f4
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
24 changes: 24 additions & 0 deletions spec/lib/presenters/page_with_step_by_step_navigation_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 2d189f4

Please sign in to comment.