From 8e93fb976ded0742e34822a91e0c0fe19b892f07 Mon Sep 17 00:00:00 2001 From: Daniel Baark <5101747+baarkerlounger@users.noreply.github.com> Date: Tue, 12 Oct 2021 10:47:33 +0100 Subject: [PATCH] =?UTF-8?q?Navigate=20straight=20to=20check=20answers=20pa?= =?UTF-8?q?ge=20if=20a=20section=20has=20been=20started=E2=80=A6=20(#41)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Navigate straight to check answers page if a section has been started already * Code review suggestion * Remove Form config specific test --- app/helpers/tasklist_helper.rb | 14 +++++++ app/views/case_logs/_tasklist.html.erb | 7 ++-- spec/features/case_log_spec.rb | 12 ------ spec/helpers/tasklist_helper_spec.rb | 51 ++++++++++++++------------ 4 files changed, 45 insertions(+), 39 deletions(-) diff --git a/app/helpers/tasklist_helper.rb b/app/helpers/tasklist_helper.rb index 4c831029c..549ef2d22 100644 --- a/app/helpers/tasklist_helper.rb +++ b/app/helpers/tasklist_helper.rb @@ -36,6 +36,15 @@ module TasklistHelper subsections.count { |subsection| get_subsection_status(subsection, case_log, form.questions_for_subsection(subsection).keys) == status } end + def get_first_page_or_check_answers(subsection, case_log, form, questions) + path = if is_started?(subsection, case_log, questions) + "case_log_#{subsection}_check_answers_path" + else + "case_log_#{form.first_page_for_subsection(subsection)}_path" + end + send(path, case_log) + end + private def all_questions_completed(case_log) @@ -46,4 +55,9 @@ private status = get_subsection_status(subsection, case_log, questions) %i[not_started in_progress].include?(status) end + + def is_started?(subsection, case_log, questions) + status = get_subsection_status(subsection, case_log, questions) + %i[in_progress completed].include?(status) + end end diff --git a/app/views/case_logs/_tasklist.html.erb b/app/views/case_logs/_tasklist.html.erb index dbbeb6321..fdf4c5aa9 100644 --- a/app/views/case_logs/_tasklist.html.erb +++ b/app/views/case_logs/_tasklist.html.erb @@ -9,9 +9,10 @@