diff --git a/app/models/form.rb b/app/models/form.rb index 57b529f10..b493c25c2 100644 --- a/app/models/form.rb +++ b/app/models/form.rb @@ -79,7 +79,7 @@ class Form when :in_progress "#{next_subsection.id}/check_answers".dasherize when :not_started - first_question_in_subsection = next_subsection.pages.first.id + first_question_in_subsection = next_subsection.pages.find { |page| page.routed_to?(case_log, nil) }.id first_question_in_subsection.to_s.dasherize else "error" diff --git a/spec/models/form_spec.rb b/spec/models/form_spec.rb index 503900ab0..291343cd9 100644 --- a/spec/models/form_spec.rb +++ b/spec/models/form_spec.rb @@ -149,9 +149,9 @@ RSpec.describe Form, type: :model do expect(form.next_incomplete_section_redirect_path(subsection, case_log)).to eq("household-needs/check-answers") end - it "returns the first page of the next incomplete subsection (skipping completed subsections)" do + it "returns the first page of the next incomplete subsection (skipping completed subsections, and pages that are not routed to)" do answer_household_needs(case_log) - expect(form.next_incomplete_section_redirect_path(subsection, case_log)).to eq("accessible-select-too") + expect(form.next_incomplete_section_redirect_path(subsection, case_log)).to eq("property-postcode") end it "returns the declaration section for a completed case log" do