Browse Source

Fix next incomplete section button when first page of next subsection… (#786)

* Fix next incomplete section button when first page of next subsection is not routed to

* Improve spec context description
pull/790/head
baarkerlounger 2 years ago committed by GitHub
parent
commit
2819850928
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      app/models/form.rb
  2. 4
      spec/models/form_spec.rb

2
app/models/form.rb

@ -79,7 +79,7 @@ class Form
when :in_progress when :in_progress
"#{next_subsection.id}/check_answers".dasherize "#{next_subsection.id}/check_answers".dasherize
when :not_started 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 first_question_in_subsection.to_s.dasherize
else else
"error" "error"

4
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") expect(form.next_incomplete_section_redirect_path(subsection, case_log)).to eq("household-needs/check-answers")
end 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) 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 end
it "returns the declaration section for a completed case log" do it "returns the declaration section for a completed case log" do

Loading…
Cancel
Save