From 8a23672ac10c883cf641627160a6e1c802bf1d63 Mon Sep 17 00:00:00 2001 From: MadeTech Dushan Date: Wed, 26 Jan 2022 17:42:26 +0000 Subject: [PATCH] fix all failures --- app/models/form.rb | 14 +++++++------- spec/factories/case_log.rb | 1 + spec/features/form/check_answers_page_spec.rb | 14 +++++++------- spec/models/form_spec.rb | 1 - 4 files changed, 15 insertions(+), 15 deletions(-) diff --git a/app/models/form.rb b/app/models/form.rb index 7076d9a20..df4d3c659 100644 --- a/app/models/form.rb +++ b/app/models/form.rb @@ -46,27 +46,27 @@ class Form "case_log_#{nxt_page}_path" end end - + def next_incomplete_section_redirect_path(subsection, case_log) subsection_ids = subsections.map(&:id) - - if(case_log.status == "completed") + + if case_log.status == "completed" next_subsection = get_subsection(subsection_ids[subsection_ids.length - 1]) first_question_in_subsection = next_subsection.pages.first.id - return "#{first_question_in_subsection}".dasherize + return first_question_in_subsection.to_s.dasherize end next_subsection_id_index = subsection_ids.index(subsection.id) + 1 next_subsection = get_subsection(subsection_ids[next_subsection_id_index]) - if(next_subsection.id == "declaration" && case_log.status != "completed") + if next_subsection.id == "declaration" && case_log.status != "completed" next_subsection = get_subsection(subsection_ids[0]) end - if(next_subsection.status(case_log) == :completed) + if next_subsection.status(case_log) == :completed next_incomplete_section_redirect_path(next_subsection, case_log) else first_question_in_subsection = next_subsection.pages.first.id - return "#{first_question_in_subsection}".dasherize + first_question_in_subsection.to_s.dasherize end end diff --git a/spec/factories/case_log.rb b/spec/factories/case_log.rb index 494febdfb..0a73e7750 100644 --- a/spec/factories/case_log.rb +++ b/spec/factories/case_log.rb @@ -151,6 +151,7 @@ FactoryBot.define do is_carehome { "No" } chcharge { 7 } letting_in_sheltered_accomodation { "No" } + la_known { "Yes" } end created_at { Time.zone.now } updated_at { Time.zone.now } diff --git a/spec/features/form/check_answers_page_spec.rb b/spec/features/form/check_answers_page_spec.rb index 94dd857b3..719ab862e 100644 --- a/spec/features/form/check_answers_page_spec.rb +++ b/spec/features/form/check_answers_page_spec.rb @@ -136,7 +136,7 @@ RSpec.describe "Form Check Answers Page" do tenant_code: "123", age1: 35, sex1: "Male", - other_hhmemb: 0 + other_hhmemb: 0, ) end @@ -154,7 +154,7 @@ RSpec.describe "Form Check Answers Page" do illness: "No", housingneeds_h: "Yes", la: "York", - illness_type_1: "Yes" + illness_type_1: "Yes", ) end @@ -169,7 +169,7 @@ RSpec.describe "Form Check Answers Page" do property_postcode: "NW1 5TY", reason: "Permanently decanted from another property owned by this landlord", previous_postcode: "SE2 6RT", - mrcdate: Time.zone.parse("03/11/2019") + mrcdate: Time.zone.parse("03/11/2019"), ) end @@ -178,20 +178,20 @@ RSpec.describe "Form Check Answers Page" do click_link("Save and go to next incomplete section") expect(page).to have_current_path("/logs/#{section_completed_case_log.id}/armed-forces") end - + it "they can click a button to skip sections until the next incomplete section" do visit("/logs/#{skip_section_case_log.id}/household-characteristics/check-answers") click_link("Save and go to next incomplete section") expect(page).to have_current_path("/logs/#{skip_section_case_log.id}/tenancy-code") - end + end it "they can click a button to cycle around to the next incomplete section" do visit("/logs/#{cycle_sections_case_log.id}/local-authority/check-answers") click_link("Save and go to next incomplete section") expect(page).to have_current_path("/logs/#{cycle_sections_case_log.id}/tenant-code") - end + end - it "they can click a button to move to the submission section when all sections have been completed", js:true do + it "they can click a button to move to the submission section when all sections have been completed", js: true do visit("/logs/#{completed_case_log.id}/local-authority/check-answers") click_link("Save and go to submit") expect(page).to have_current_path("/logs/#{completed_case_log.id}/declaration") diff --git a/spec/models/form_spec.rb b/spec/models/form_spec.rb index 8d094d5af..9a09fc635 100644 --- a/spec/models/form_spec.rb +++ b/spec/models/form_spec.rb @@ -39,7 +39,6 @@ RSpec.describe Form, type: :model do let(:later_subsection) { form.get_subsection("local_authority") } context "when a user is on the check answers page for a subsection" do - before do case_log.tenant_code = "123" case_log.age1 = 35