From 74d75024bfd0a74222e2ad8c6412eb1e370985d0 Mon Sep 17 00:00:00 2001 From: baarkerlounger Date: Wed, 12 Jan 2022 18:37:14 +0000 Subject: [PATCH] Don't make subsection labels links if they're not enabled --- app/helpers/tasklist_helper.rb | 12 ++++++------ spec/helpers/tasklist_helper_spec.rb | 4 ++-- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/app/helpers/tasklist_helper.rb b/app/helpers/tasklist_helper.rb index a6935f620..fa4543d25 100644 --- a/app/helpers/tasklist_helper.rb +++ b/app/helpers/tasklist_helper.rb @@ -35,11 +35,11 @@ module TasklistHelper end def subsection_link(subsection, case_log) - next_page_path = if subsection.status(case_log) != :cannot_start_yet - first_page_or_check_answers(subsection, case_log) - else - "#" - end - govuk_link_to(subsection.label, next_page_path.to_s.dasherize, class: "task-name") + if subsection.status(case_log) != :cannot_start_yet + next_page_path = first_page_or_check_answers(subsection, case_log).to_s + govuk_link_to(subsection.label, next_page_path.dasherize, class: "task-name") + else + subsection.label + end end end diff --git a/spec/helpers/tasklist_helper_spec.rb b/spec/helpers/tasklist_helper_spec.rb index d55cd8258..684097768 100644 --- a/spec/helpers/tasklist_helper_spec.rb +++ b/spec/helpers/tasklist_helper_spec.rb @@ -67,8 +67,8 @@ RSpec.describe TasklistHelper do allow(subsection).to receive(:status).with(case_log).and_return(:cannot_start_yet) end - it "returns a # link" do - expect(subsection_link(subsection, case_log)).to match(/#/) + it "returns the label instead of a link" do + expect(subsection_link(subsection, case_log)).to match(subsection.label) end end end