From 5ab96154dad858b3406f63880ab02e1f4e14a0e5 Mon Sep 17 00:00:00 2001 From: Paul Robert Lloyd Date: Mon, 21 Mar 2022 15:20:56 +0000 Subject: [PATCH] Update status of log on log page --- app/views/case_logs/edit.html.erb | 36 ++++++++++++------------ spec/features/form/tasklist_page_spec.rb | 13 +++++---- 2 files changed, 25 insertions(+), 24 deletions(-) diff --git a/app/views/case_logs/edit.html.erb b/app/views/case_logs/edit.html.erb index fa3942b14..28b2eacd6 100644 --- a/app/views/case_logs/edit.html.erb +++ b/app/views/case_logs/edit.html.erb @@ -11,25 +11,25 @@ <%= content_for(:title) %> -

- This log is - <%= @case_log.status.to_s.humanize.downcase %> -

+ <% if @case_log.status == "in_progress" %> +

<%= get_subsections_count(@case_log, :completed) %> of <%= get_subsections_count(@case_log, :all) %> sections completed.

+

+ <% next_incomplete_section = get_next_incomplete_section(@case_log) %> +

+

+ <% if next_incomplete_section.present? %> + > + Skip to next incomplete section: <%= next_incomplete_section.label %> + + <% end %> +

+ <% elsif @case_log.status == "not_started" %> +

This log has not been started.

+ <% end %> -

You have completed <%= get_subsections_count(@case_log, :completed) %> of <%= get_subsections_count(@case_log, :all) %> sections.

-

- <% next_incomplete_section = get_next_incomplete_section(@case_log) %> -

-

- <% if next_incomplete_section.present? %> - > - Skip to next incomplete section: <%= next_incomplete_section.label %> - - <% end %> -

<%= render "tasklist" %> diff --git a/spec/features/form/tasklist_page_spec.rb b/spec/features/form/tasklist_page_spec.rb index ba731e05e..7f869ded4 100644 --- a/spec/features/form/tasklist_page_spec.rb +++ b/spec/features/form/tasklist_page_spec.rb @@ -26,19 +26,20 @@ RSpec.describe "Task List" do sign_in user end - it "skips to the first section if no answers are completed" do + it "shows if the section has not been started" do visit("/logs/#{empty_case_log.id}") - expect(page).to have_link("Skip to next incomplete section", href: /#household_characteristics/) + expect(page).to have_content("This log has not been started.") end - it "shows the number of completed sections if no sections are completed" do + it "shows number of completed sections if one section is completed" do + answer_all_questions_in_income_subsection(empty_case_log) visit("/logs/#{empty_case_log.id}") - expect(page).to have_content("You have completed 0 of 9 sections.") + expect(page).to have_content("1 of 9 sections completed.") end - it "shows the number of completed sections if one section is completed" do + it "show skip link for next incomplete section" do answer_all_questions_in_income_subsection(empty_case_log) visit("/logs/#{empty_case_log.id}") - expect(page).to have_content("You have completed 1 of 9 sections.") + expect(page).to have_link("Skip to next incomplete section", href: /#household-characteristics/) end end