Browse Source

Don't make subsection labels links if they're not enabled

pull/215/head
baarkerlounger 4 years ago
parent
commit
74d75024bf
  1. 12
      app/helpers/tasklist_helper.rb
  2. 4
      spec/helpers/tasklist_helper_spec.rb

12
app/helpers/tasklist_helper.rb

@ -35,11 +35,11 @@ module TasklistHelper
end end
def subsection_link(subsection, case_log) def subsection_link(subsection, case_log)
next_page_path = if subsection.status(case_log) != :cannot_start_yet if subsection.status(case_log) != :cannot_start_yet
first_page_or_check_answers(subsection, case_log) next_page_path = first_page_or_check_answers(subsection, case_log).to_s
else govuk_link_to(subsection.label, next_page_path.dasherize, class: "task-name")
"#" else
end subsection.label
govuk_link_to(subsection.label, next_page_path.to_s.dasherize, class: "task-name") end
end end
end end

4
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) allow(subsection).to receive(:status).with(case_log).and_return(:cannot_start_yet)
end end
it "returns a # link" do it "returns the label instead of a link" do
expect(subsection_link(subsection, case_log)).to match(/#/) expect(subsection_link(subsection, case_log)).to match(subsection.label)
end end
end end
end end

Loading…
Cancel
Save