diff --git a/app/helpers/tasklist_helper.rb b/app/helpers/tasklist_helper.rb index 5ca37b56c..d9b402221 100644 --- a/app/helpers/tasklist_helper.rb +++ b/app/helpers/tasklist_helper.rb @@ -6,9 +6,9 @@ module TasklistHelper end def get_subsections_count(case_log, status = :all) - return case_log.form.subsections.count if status == :all + return case_log.form.subsections.count { |subsection| subsection.applicable_questions(case_log).count.positive? } if status == :all - case_log.form.subsections.count { |subsection| subsection.status(case_log) == status } + case_log.form.subsections.count { |subsection| subsection.status(case_log) == status && subsection.applicable_questions(case_log).count.positive? } end def next_page_or_check_answers(subsection, case_log, current_user) diff --git a/app/models/form/subsection.rb b/app/models/form/subsection.rb index 7c6d86698..80a4db102 100644 --- a/app/models/form/subsection.rb +++ b/app/models/form/subsection.rb @@ -34,7 +34,7 @@ class Form::Subsection qs = applicable_questions(case_log) qs_optional_removed = qs.reject { |q| case_log.optional_fields.include?(q.id) } - return :not_started if qs.all? { |question| case_log[question.id].blank? || question.read_only? || question.derived? } + return :not_started if qs.count.positive? && qs.all? { |question| case_log[question.id].blank? || question.read_only? || question.derived? } return :completed if qs_optional_removed.all? { |question| question.completed?(case_log) } :in_progress diff --git a/spec/features/form/tasklist_page_spec.rb b/spec/features/form/tasklist_page_spec.rb index c2c4da0c6..25f2824ac 100644 --- a/spec/features/form/tasklist_page_spec.rb +++ b/spec/features/form/tasklist_page_spec.rb @@ -54,7 +54,7 @@ RSpec.describe "Task List" do it "shows number of completed sections if one section is completed" do visit("/logs/#{setup_completed_log.id}") - expect(page).to have_content("1 of 9 sections completed.") + expect(page).to have_content("1 of 8 sections completed.") end it "show skip link for next incomplete section" do diff --git a/spec/helpers/tasklist_helper_spec.rb b/spec/helpers/tasklist_helper_spec.rb index 0e13fa805..4401d1739 100644 --- a/spec/helpers/tasklist_helper_spec.rb +++ b/spec/helpers/tasklist_helper_spec.rb @@ -17,7 +17,7 @@ RSpec.describe TasklistHelper do describe "get sections count" do it "returns the total of sections if no status is given" do - expect(get_subsections_count(empty_case_log)).to eq(9) + expect(get_subsections_count(empty_case_log)).to eq(8) end it "returns 0 sections for completed sections if no sections are completed" do