Browse Source

fix all failures

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

14
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

1
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 }

14
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")

1
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

Loading…
Cancel
Save