From 28198509281b26a24446e8773badba79a57bb117 Mon Sep 17 00:00:00 2001 From: baarkerlounger <5101747+baarkerlounger@users.noreply.github.com> Date: Wed, 27 Jul 2022 11:03:47 +0100 Subject: [PATCH] =?UTF-8?q?Fix=20next=20incomplete=20section=20button=20wh?= =?UTF-8?q?en=20first=20page=20of=20next=20subsection=E2=80=A6=20(#786)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Fix next incomplete section button when first page of next subsection is not routed to * Improve spec context description --- app/models/form.rb | 2 +- spec/models/form_spec.rb | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) 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