Skip to content

Commit

Permalink
Refactor related_to_step_navs function to superceed the original check
Browse files Browse the repository at this point in the history
This is required because the show_related_links function is used by
content_tagged_to_a_reasonable_number_of_step_by_steps which is
used to display the heading of the step by step.

When a content item has step by step turned off by default, it will
not contain any step_navs objects - as this is a `&&` statement, it will
return false straight away. Inside the active_step_by_step? function,
we merge both lists together, therefore, will display the related step
by step links where appropriate.
  • Loading branch information
Dilwoar Hussain committed Sep 25, 2018
1 parent 39d42c0 commit dd62c7a
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ def show_header?
end

def show_related_links?
step_navs.any? && (step_navs.count < 5 || active_step_by_step?)
return true if active_step_by_step?
step_navs.any? && step_navs.count < 5
end

def show_also_part_of_step_nav?
Expand Down
18 changes: 18 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 @@ -381,6 +381,24 @@
expect(step_nav_helper.active_step_by_step?).to eq(false)
expect(step_nav_helper.show_also_part_of_step_nav?).to be false
end

it "shows header for related to step nav when a step by step is active" do
step_nav = {
"content_id" => "cccc-dddd",
"title" => "Learn to spacewalk: small step by giant leap",
"base_path" => "/learn-to-spacewalk"
}
content_item = {
"title" => "Book a session in the vomit comet",
"document_type" => "transaction",
"links" => {
"related_to_step_navs" => [step_nav],
}
}
step_nav_helper = described_class.new(content_item, "/driving-lessons-learning-to-drive", "step-by-step-nav" => "cccc-dddd")
expect(step_nav_helper.active_step_by_step?).to eq(true)
expect(step_nav_helper.show_header?).to eq(true)
end
end

def payload_for(schema, content_item)
Expand Down

0 comments on commit dd62c7a

Please sign in to comment.