Browse Source

fix all failures

pull/252/head
MadeTech Dushan 3 years ago
parent
commit
8a23672ac1
  1. 10
      app/models/form.rb
  2. 1
      spec/factories/case_log.rb
  3. 6
      spec/features/form/check_answers_page_spec.rb
  4. 1
      spec/models/form_spec.rb

10
app/models/form.rb

@ -50,23 +50,23 @@ class Form
def next_incomplete_section_redirect_path(subsection, case_log) def next_incomplete_section_redirect_path(subsection, case_log)
subsection_ids = subsections.map(&:id) 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]) next_subsection = get_subsection(subsection_ids[subsection_ids.length - 1])
first_question_in_subsection = next_subsection.pages.first.id first_question_in_subsection = next_subsection.pages.first.id
return "#{first_question_in_subsection}".dasherize return first_question_in_subsection.to_s.dasherize
end end
next_subsection_id_index = subsection_ids.index(subsection.id) + 1 next_subsection_id_index = subsection_ids.index(subsection.id) + 1
next_subsection = get_subsection(subsection_ids[next_subsection_id_index]) 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]) next_subsection = get_subsection(subsection_ids[0])
end end
if(next_subsection.status(case_log) == :completed) if next_subsection.status(case_log) == :completed
next_incomplete_section_redirect_path(next_subsection, case_log) next_incomplete_section_redirect_path(next_subsection, case_log)
else else
first_question_in_subsection = next_subsection.pages.first.id first_question_in_subsection = next_subsection.pages.first.id
return "#{first_question_in_subsection}".dasherize first_question_in_subsection.to_s.dasherize
end end
end end

1
spec/factories/case_log.rb

@ -151,6 +151,7 @@ FactoryBot.define do
is_carehome { "No" } is_carehome { "No" }
chcharge { 7 } chcharge { 7 }
letting_in_sheltered_accomodation { "No" } letting_in_sheltered_accomodation { "No" }
la_known { "Yes" }
end end
created_at { Time.zone.now } created_at { Time.zone.now }
updated_at { Time.zone.now } updated_at { Time.zone.now }

6
spec/features/form/check_answers_page_spec.rb

@ -136,7 +136,7 @@ RSpec.describe "Form Check Answers Page" do
tenant_code: "123", tenant_code: "123",
age1: 35, age1: 35,
sex1: "Male", sex1: "Male",
other_hhmemb: 0 other_hhmemb: 0,
) )
end end
@ -154,7 +154,7 @@ RSpec.describe "Form Check Answers Page" do
illness: "No", illness: "No",
housingneeds_h: "Yes", housingneeds_h: "Yes",
la: "York", la: "York",
illness_type_1: "Yes" illness_type_1: "Yes",
) )
end end
@ -169,7 +169,7 @@ RSpec.describe "Form Check Answers Page" do
property_postcode: "NW1 5TY", property_postcode: "NW1 5TY",
reason: "Permanently decanted from another property owned by this landlord", reason: "Permanently decanted from another property owned by this landlord",
previous_postcode: "SE2 6RT", previous_postcode: "SE2 6RT",
mrcdate: Time.zone.parse("03/11/2019") mrcdate: Time.zone.parse("03/11/2019"),
) )
end end

1
spec/models/form_spec.rb

@ -39,7 +39,6 @@ RSpec.describe Form, type: :model do
let(:later_subsection) { form.get_subsection("local_authority") } let(:later_subsection) { form.get_subsection("local_authority") }
context "when a user is on the check answers page for a subsection" do context "when a user is on the check answers page for a subsection" do
before do before do
case_log.tenant_code = "123" case_log.tenant_code = "123"
case_log.age1 = 35 case_log.age1 = 35

Loading…
Cancel
Save