Skip to content

Commit

Permalink
Do not show also part of if there are more than 5 in step navs
Browse files Browse the repository at this point in the history
  • Loading branch information
Dilwoar Hussain committed Sep 25, 2018
1 parent 2d189f4 commit 3f061d8
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def show_related_links?
end

def show_also_part_of_step_nav?
active_step_by_step? && also_part_of_step_nav.any?
active_step_by_step? && also_part_of_step_nav.any? && step_navs_combined_list.count < 5
end

def related_links
Expand Down
49 changes: 49 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 @@ -423,6 +423,55 @@
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

it "does not show part of step navs if more than 5" 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"
}
another_step_nav2 = {
"content_id" => "aaaa-bbbb",
"title" => "Lose your lunch: lurch by lurch 2",
"base_path" => "/lose-your-lunch-2"
}
another_step_nav3 = {
"content_id" => "aaaa-bbbb",
"title" => "Lose your lunch: lurch by lurch 3",
"base_path" => "/lose-your-lunch-3"
}
another_step_nav4 = {
"content_id" => "aaaa-bbbb",
"title" => "Lose your lunch: lurch by lurch 4",
"base_path" => "/lose-your-lunch-4"
}
another_step_nav5 = {
"content_id" => "aaaa-bbbb",
"title" => "Lose your lunch: lurch by lurch 5",
"base_path" => "/lose-your-lunch-5"
}
content_item_in_six_step_navs = {
"title" => "Book a session in the vomit comet",
"document_type" => "transaction",
"links" => {
"related_to_step_navs" => [
step_nav,
another_step_nav,
another_step_nav2,
another_step_nav3,
another_step_nav4,
another_step_nav5,
],
}
}
step_nav_helper = described_class.new(content_item_in_six_step_navs, "/driving-lessons-learning-to-drive", "step-by-step-nav" => "cccc-dddd")
expect(step_nav_helper.show_also_part_of_step_nav?).to eq(false)
end
end

def payload_for(schema, content_item)
Expand Down

0 comments on commit 3f061d8

Please sign in to comment.