|
|
@ -39,66 +39,85 @@ 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 |
|
|
|
def answer_household_needs(case_log) |
|
|
|
case_log.tenant_code = "123" |
|
|
|
|
|
|
|
case_log.age1 = 35 |
|
|
|
|
|
|
|
case_log.sex1 = "Male" |
|
|
|
|
|
|
|
case_log.other_hhmemb = 0 |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
it "returns the first page of the next incomplete subsection" do |
|
|
|
|
|
|
|
expect(form.next_incomplete_section_redirect_path(subsection, case_log)).to eq("armed-forces") |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
it "returns the first page of the next incomplete subsection (skipping completed subsections)" do |
|
|
|
|
|
|
|
case_log.armedforces = "No" |
|
|
|
case_log.armedforces = "No" |
|
|
|
case_log.illness = "No" |
|
|
|
case_log.illness = "No" |
|
|
|
case_log.housingneeds_a = "Yes" |
|
|
|
case_log.housingneeds_a = "Yes" |
|
|
|
case_log.la = "York" |
|
|
|
case_log.la = "York" |
|
|
|
case_log.illness_type_1 = "Yes" |
|
|
|
case_log.illness_type_1 = "Yes" |
|
|
|
expect(form.next_incomplete_section_redirect_path(subsection, case_log)).to eq("tenancy-code") |
|
|
|
|
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
it "returns the next incomplete section by cycling back around if next subsections are completed" do |
|
|
|
def answer_tenancy_information(case_log) |
|
|
|
case_log.layear = "1 to 2 years" |
|
|
|
case_log.tenancy_code = "1234" |
|
|
|
case_log.lawaitlist = "Less than 1 year" |
|
|
|
|
|
|
|
case_log.property_postcode = "NW1 5TY" |
|
|
|
|
|
|
|
case_log.reason = "Permanently decanted from another property owned by this landlord" |
|
|
|
|
|
|
|
case_log.previous_postcode = "SE2 6RT" |
|
|
|
|
|
|
|
case_log.mrcdate = Time.zone.parse("03/11/2019") |
|
|
|
|
|
|
|
expect(form.next_incomplete_section_redirect_path(later_subsection, case_log)).to eq("armed-forces") |
|
|
|
|
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
it "returns the declaration section for a completed case log" do |
|
|
|
def answer_property_information(case_log) |
|
|
|
expect(form.next_incomplete_section_redirect_path(subsection, completed_case_log)).to eq("declaration") |
|
|
|
case_log.wchair = "No" |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
it "returns the declaration section if all sections are complete but the case log is in progress" do |
|
|
|
def answer_conditional_question(case_log) |
|
|
|
case_log.armedforces = "No" |
|
|
|
|
|
|
|
case_log.illness = "No" |
|
|
|
|
|
|
|
case_log.housingneeds_a = "Yes" |
|
|
|
|
|
|
|
case_log.la = "York" |
|
|
|
|
|
|
|
case_log.illness_type_1 = "Yes" |
|
|
|
|
|
|
|
case_log.tenancy_code = "1234" |
|
|
|
|
|
|
|
case_log.wchair = "No" |
|
|
|
|
|
|
|
case_log.preg_occ = "No" |
|
|
|
case_log.preg_occ = "No" |
|
|
|
case_log.cbl = "No" |
|
|
|
case_log.cbl = "No" |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def answer_income_and_benefits(case_log) |
|
|
|
case_log.earnings = 30_000 |
|
|
|
case_log.earnings = 30_000 |
|
|
|
case_log.incfreq = "Yearly" |
|
|
|
case_log.incfreq = "Yearly" |
|
|
|
case_log.benefits = "Some" |
|
|
|
case_log.benefits = "Some" |
|
|
|
case_log.hb = "Tenant prefers not to say" |
|
|
|
case_log.hb = "Tenant prefers not to say" |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def answer_rent_and_charges(case_log) |
|
|
|
case_log.period = "Every 2 weeks" |
|
|
|
case_log.period = "Every 2 weeks" |
|
|
|
case_log.brent = 650 |
|
|
|
case_log.brent = 650 |
|
|
|
case_log.scharge = 0 |
|
|
|
case_log.scharge = 0 |
|
|
|
case_log.pscharge = 0 |
|
|
|
case_log.pscharge = 0 |
|
|
|
case_log.supcharg = 0 |
|
|
|
case_log.supcharg = 0 |
|
|
|
case_log.tcharge = 650 |
|
|
|
case_log.tcharge = 650 |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def answer_local_authority(case_log) |
|
|
|
case_log.layear = "1 to 2 years" |
|
|
|
case_log.layear = "1 to 2 years" |
|
|
|
case_log.lawaitlist = "Less than 1 year" |
|
|
|
case_log.lawaitlist = "Less than 1 year" |
|
|
|
case_log.property_postcode = "NW1 5TY" |
|
|
|
case_log.property_postcode = "NW1 5TY" |
|
|
|
case_log.reason = "Permanently decanted from another property owned by this landlord" |
|
|
|
case_log.reason = "Permanently decanted from another property owned by this landlord" |
|
|
|
case_log.previous_postcode = "SE2 6RT" |
|
|
|
case_log.previous_postcode = "SE2 6RT" |
|
|
|
case_log.mrcdate = Time.zone.parse("03/11/2019") |
|
|
|
case_log.mrcdate = Time.zone.parse("03/11/2019") |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
before do |
|
|
|
|
|
|
|
case_log.tenant_code = "123" |
|
|
|
|
|
|
|
case_log.age1 = 35 |
|
|
|
|
|
|
|
case_log.sex1 = "Male" |
|
|
|
|
|
|
|
case_log.other_hhmemb = 0 |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
it "returns the first page of the next incomplete subsection" do |
|
|
|
|
|
|
|
expect(form.next_incomplete_section_redirect_path(subsection, case_log)).to eq("armed-forces") |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
it "returns the first page of the next incomplete subsection (skipping completed subsections)" do |
|
|
|
|
|
|
|
answer_household_needs(case_log) |
|
|
|
|
|
|
|
expect(form.next_incomplete_section_redirect_path(subsection, case_log)).to eq("tenancy-code") |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
it "returns the next incomplete section by cycling back around if next subsections are completed" do |
|
|
|
|
|
|
|
answer_local_authority(case_log) |
|
|
|
|
|
|
|
expect(form.next_incomplete_section_redirect_path(later_subsection, case_log)).to eq("armed-forces") |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
it "returns the declaration section for a completed case log" do |
|
|
|
|
|
|
|
expect(form.next_incomplete_section_redirect_path(subsection, completed_case_log)).to eq("declaration") |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
it "returns the declaration section if all sections are complete but the case log is in progress" do |
|
|
|
|
|
|
|
answer_household_needs(case_log) |
|
|
|
|
|
|
|
answer_tenancy_information(case_log) |
|
|
|
|
|
|
|
answer_property_information(case_log) |
|
|
|
|
|
|
|
answer_conditional_question(case_log) |
|
|
|
|
|
|
|
answer_income_and_benefits(case_log) |
|
|
|
|
|
|
|
answer_rent_and_charges(case_log) |
|
|
|
|
|
|
|
answer_local_authority(case_log) |
|
|
|
|
|
|
|
|
|
|
|
expect(form.next_incomplete_section_redirect_path(subsection, case_log)).to eq("declaration") |
|
|
|
expect(form.next_incomplete_section_redirect_path(subsection, case_log)).to eq("declaration") |
|
|
|
end |
|
|
|
end |
|
|
|