From aea12947eb1876e4836c06c1ee2cd36799216736 Mon Sep 17 00:00:00 2001 From: Dushan <47317567+dushan-madetech@users.noreply.github.com> Date: Wed, 23 Feb 2022 13:41:21 +0000 Subject: [PATCH] CLDC-630: Household needs section (#311) * household needs section change * update enums * fix specs * spec fixes * content updates to form * fix failing spec * remove hint text * Update config/forms/2021_2022.json Co-authored-by: Paul Robert Lloyd Co-authored-by: Paul Robert Lloyd --- app/models/constants/case_log.rb | 16 +- .../validations/household_validations.rb | 6 +- config/forms/2021_2022.json | 470 +++++++++--------- docs/api/DLUHC-CORE-Data.v1.json | 2 +- spec/factories/case_log.rb | 2 +- .../form/conditional_questions_spec.rb | 4 +- spec/fixtures/complete_case_log.json | 6 +- spec/fixtures/forms/2021_2022.json | 18 +- .../conditional_questions_helper_spec.rb | 2 +- .../validations/household_validations_spec.rb | 14 +- 10 files changed, 272 insertions(+), 268 deletions(-) diff --git a/app/models/constants/case_log.rb b/app/models/constants/case_log.rb index 6d3f46e1e..9985120de 100644 --- a/app/models/constants/case_log.rb +++ b/app/models/constants/case_log.rb @@ -70,9 +70,9 @@ module Constants::CaseLog LEFTREG = { "Yes" => 6, - "No - they left up to 5 years ago" => 4, - "No - they left more than 5 years ago" => 5, - "Prefer not to say" => 3, + "No, they left up to and including 5 years ago" => 4, + "No, they left more than 5 years ago" => 5, + "Person prefers not to say" => 3, }.freeze NATIONAL = { @@ -99,7 +99,7 @@ module Constants::CaseLog PREGNANCY = { "Yes" => 1, "No" => 2, - "Prefer not to say" => 3, + "Tenant prefers not to say" => 3, }.freeze PREVIOUS_TENANCY = { @@ -980,11 +980,11 @@ module Constants::CaseLog }.freeze ARMED_FORCES = { - "A current or former regular in the UK Armed Forces (excluding National Service)" => 1, + "Yes, the person is a current or former regular" => 1, "No" => 2, - "Tenant prefers not to say" => 3, - "A current or former reserve in the UK Armed Forces (excluding National Service)" => 4, - "A spouse / civil partner of a UK Armed Forces member who has separated or been bereaved within the last 2 years" => 5, + "Person prefers not to say" => 3, + "Yes, the person is a current or former reserve" => 4, + "Yes, the tenant is a spouse or civil partner of a UK armed forces member and has been bereaved or separated from them within the last 2 years" => 5, }.freeze RENT_TYPE = { diff --git a/app/models/validations/household_validations.rb b/app/models/validations/household_validations.rb index 5b3d7c4d1..58997fb9d 100644 --- a/app/models/validations/household_validations.rb +++ b/app/models/validations/household_validations.rb @@ -24,16 +24,16 @@ module Validations::HouseholdValidations end def validate_armed_forces(record) - if (record.armedforces == "No" || record.armedforces == "Tenant prefers not to say") && record.reservist.present? + if (record.armedforces == "No" || record.armedforces == "Person prefers not to say") && record.reservist.present? record.errors.add :reservist, I18n.t("validations.household.reservist.injury_not_required") end - if record.armedforces != "A current or former regular in the UK Armed Forces (excluding National Service)" && record.leftreg.present? + if record.armedforces != "Yes, the person is a current or former regular" && record.leftreg.present? record.errors.add :leftreg, I18n.t("validations.household.leftreg.question_not_required") end end def validate_pregnancy(record) - if (record.preg_occ == "Yes" || record.preg_occ == "Prefer not to say") && !women_of_child_bearing_age_in_household(record) + if (record.preg_occ == "Yes" || record.preg_occ == "Tenant prefers not to say") && !women_of_child_bearing_age_in_household(record) record.errors.add :preg_occ, I18n.t("validations.household.preg_occ.no_female") end end diff --git a/config/forms/2021_2022.json b/config/forms/2021_2022.json index 95f9ec429..ffe3b0cb6 100644 --- a/config/forms/2021_2022.json +++ b/config/forms/2021_2022.json @@ -2042,6 +2042,243 @@ } } }, + "household_needs": { + "label": "Household needs", + "depends_on": [ + { + "setup": "completed" + } + ], + "pages": { + "armed_forces": { + "header": "", + "description": "", + "questions": { + "armedforces": { + "header": "Does anybody in the household have any links to the UK armed forces?", + "hint_text": "This excludes national service.

If there are several people in the household with links to the UK armed forces, you should answer for the regular. If there’s no regular, answer for the reserve. If there’s no reserve, answer for the spouse or civil partner.", + "type": "radio", + "check_answer_label": "Household links to UK armed forces", + "answer_options": { + "0": { + "value": "Yes, the person is a current or former regular" + }, + "1": { + "value": "Yes, the person is a current or former reserve" + }, + "2": { + "value": "Yes, the person is a spouse or civil partner of a UK armed forces member and has been bereaved or separated from them within the last 2 years" + }, + "3": { + "value": "No" + }, + "4": { + "value": "Person prefers not to say" + } + } + } + } + }, + "armed_forces_member": { + "header": "", + "description": "", + "depends_on": [ + { + "armedforces": "Yes, the person is a current or former regular" + } + ], + "questions": { + "leftreg": { + "header": "Is the person still serving in the UK armed forces?", + "hint_text": "", + "type": "radio", + "check_answer_label": "Person still serving in UK armed forces", + "answer_options": { + "0": { + "value": "Yes" + }, + "1": { + "value": "No, they left up to and including 5 years ago" + }, + "2": { + "value": "No, they left more than 5 years ago" + }, + "3": { + "value": "Person prefers not to say" + } + } + } + } + }, + "armed_forces_reservist": { + "header": "", + "description": "", + "depends_on": [ + { + "armedforces": "Yes, the person is a current or former regular" + }, + { + "armedforces": "Yes, the person is a current or former reserve" + } + ], + "questions": { + "reservist": { + "header": "Was the person seriously injured or ill as a result of serving in the UK armed forces?", + "hint_text": "", + "type": "radio", + "check_answer_label": "Person seriously injured or ill as result of serving in UK armed forces", + "answer_options": { + "0": { + "value": "Yes" + }, + "1": { + "value": "No" + }, + "2": { + "value": "Person prefers not to say" + } + } + } + } + }, + "pregnancy": { + "header": "", + "description": "", + "questions": { + "preg_occ": { + "header": "Is anybody in the household pregnant?", + "hint_text": "", + "type": "radio", + "check_answer_label": "Anybody in household pregnant", + "answer_options": { + "0": { + "value": "Yes" + }, + "1": { + "value": "No" + }, + "2": { + "value": "Tenant prefers not to say" + } + } + } + } + }, + "accessibility_requirements": { + "header": "", + "description": "", + "questions": { + "accessibility_requirements": { + "header": "Does anybody in the household have any disabled access needs?", + "hint_text": "", + "type": "checkbox", + "check_answer_label": "Anybody in household with disabled access needs", + "answer_options": { + "housingneeds_a": { + "value": "Fully wheelchair accessible housing" + }, + "housingneeds_b": { + "value": "Wheelchair access to essential rooms" + }, + "housingneeds_c": { + "value": "Level access housing" + }, + "housingneeds_f": { + "value": "Other disabled access needs" + }, + "divider": { + "value": true + }, + "housingneeds_g": { + "value": "No disabled access needs" + }, + "housingneeds_h": { + "value": "Don’t know" + } + } + } + } + }, + "medical_conditions": { + "header": "", + "description": "", + "questions": { + "illness": { + "header": "Does anybody in the household have a physical or mental health condition (or other illness) expected to last 12 months or more?", + "hint_text": "", + "type": "radio", + "check_answer_label": "Anybody in household with physical or mental health condition", + "answer_options": { + "0": { + "value": "Yes" + }, + "1": { + "value": "No" + }, + "2": { + "value": "Tenant prefers not to say" + } + } + } + } + }, + "condition_effects": { + "header": "", + "description": "", + "depends_on": [ + { + "illness": "Yes" + } + ], + "questions": { + "condition_effects": { + "header": "How is the person affected by their condition or illness?", + "hint_text": "Select all that apply.", + "type": "checkbox", + "check_answer_label": "How is person affected by condition or illness", + "answer_options": { + "illness_type_1": { + "value": "Vision", + "hint": "For example, blindness or partial sight." + }, + "illness_type_2": { + "value": "Hearing", + "hint": "For example, deafness or partial hearing." + }, + "illness_type_3": { + "value": "Mobility", + "hint": "For example, walking short distances or climbing stairs." + }, + "illness_type_4": { + "value": "Dexterity", + "hint": "For example, lifting and carrying objects or using a keyboard." + }, + "illness_type_5": { + "value": "Learning or understanding or concentrating" + }, + "illness_type_6": { + "value": "Memory" + }, + "illness_type_7": { + "value": "Mental health", + "hint": "For example, depression or anxiety." + }, + "illness_type_8": { + "value": "Stamina or breathing or fatigue" + }, + "illness_type_9": { + "value": "Socially or behaviourally", + "hint": "For example, associated with autism spectrum disorder (ASD) which includes Asperger’s or attention deficit hyperactivity disorder (ADHD)." + }, + "illness_type_10": { + "value": "Other" + } + } + } + } + } + } + }, "household_situation": { "label": "Household situation", "depends_on": [ @@ -3216,239 +3453,6 @@ ] } } - }, - "household_needs": { - "label": "Household needs", - "depends_on": [ - { - "setup": "completed" - } - ], - "pages": { - "armed_forces": { - "header": "Experience of the UK Armed Forces", - "description": "", - "questions": { - "armedforces": { - "header": "Is anyone in the household...", - "hint_text": "This excludes national service.", - "type": "radio", - "check_answer_label": "Armed Forces", - "answer_options": { - "0": { - "value": "A current or former regular in the UK Armed Forces (excluding National Service)" - }, - "1": { - "value": "A current or former reserve in the UK Armed Forces (excluding National Service)" - }, - "2": { - "value": "A spouse / civil partner of a UK Armed Forces member who has separated or been bereaved within the last 2 years" - }, - "3": { - "value": "No" - }, - "4": { - "value": "Tenant prefers not to say" - } - } - } - } - }, - "armed_forces_member": { - "header": "Experience of the UK Armed Forces", - "description": "", - "depends_on": [ - { - "armedforces": "A current or former regular in the UK Armed Forces (excluding National Service)" - } - ], - "questions": { - "leftreg": { - "header": "Are they still serving?", - "hint_text": "", - "type": "radio", - "check_answer_label": "When did they leave the Armed Forces?", - "answer_options": { - "0": { - "value": "Yes" - }, - "1": { - "value": "No - they left up to 5 years ago" - }, - "2": { - "value": "No - they left more than 5 years ago" - }, - "3": { - "value": "Prefer not to say" - }, - "divider": { - "value": true - } - } - }, - "reservist": { - "header": "Were they seriously injured or ill as a result of their service?", - "hint_text": "", - "type": "radio", - "check_answer_label": "Has anyone in the household been seriously injured or ill as a result of their service in the armed forces?", - "answer_options": { - "0": { - "value": "Yes" - }, - "1": { - "value": "No" - }, - "2": { - "value": "Prefer not to say" - }, - "divider": { - "value": true - } - } - } - } - }, - "medical_conditions": { - "header": "", - "description": "", - "questions": { - "illness": { - "header": "Does anyone in the household have any of the following that they expect to last for 12 months or more:", - "hint_text": "", - "type": "radio", - "check_answer_label": "Physical, mental health or illness in the household", - "answer_options": { - "0": { - "value": "Yes" - }, - "1": { - "value": "No" - }, - "2": { - "value": "Prefer not to say" - }, - "divider": { - "value": true - } - } - } - } - }, - "pregnancy": { - "header": "", - "description": "", - "questions": { - "preg_occ": { - "header": "Is anyone in the household pregnant?", - "hint_text": "", - "type": "radio", - "check_answer_label": "Pregnancy in the household", - "answer_options": { - "0": { - "value": "Yes" - }, - "1": { - "value": "No" - }, - "2": { - "value": "Prefer not to say" - }, - "divider": { - "value": true - } - } - } - } - }, - "accessibility_requirements": { - "header": "", - "description": "", - "questions": { - "accessibility_requirements": { - "header": "Are any of these affected by their condition or illness?", - "hint_text": "Select all that apply.", - "type": "checkbox", - "check_answer_label": "Disability requirements", - "answer_options": { - "housingneeds_a": { - "value": "Fully wheelchair accessible housing" - }, - "housingneeds_b": { - "value": "Wheelchair access to essential rooms" - }, - "housingneeds_c": { - "value": "Level access housing" - }, - "housingneeds_f": { - "value": "Other disability requirements" - }, - "housingneeds_g": { - "value": "No disability requirements" - }, - "divider": { - "value": true - }, - "housingneeds_h": { - "value": "Don’t know" - }, - "accessibility_requirements_prefer_not_to_say": { - "value": "Prefer not to say" - } - } - } - } - }, - "condition_effects": { - "header": "", - "description": "", - "questions": { - "condition_effects": { - "header": "Are any of these affected by their condition or illness?", - "hint_text": "Select all that apply.", - "type": "checkbox", - "check_answer_label": "Conditions or illnesses", - "answer_options": { - "illness_type_1": { - "value": "Vision", - "hint": "For example, blindness or partial sight." - }, - "illness_type_2": { - "value": "Hearing", - "hint": "For example, deafness or partial hearing." - }, - "illness_type_3": { - "value": "Mobility", - "hint": "For example, walking short distances or climbing stairs." - }, - "illness_type_4": { - "value": "Dexterity", - "hint": "For example, lifting and carrying objects or using a keyboard." - }, - "illness_type_8": { - "value": "Stamina or breathing or fatigue" - }, - "illness_type_5": { - "value": "Learning or understanding or concentrating" - }, - "illness_type_6": { - "value": "Memory" - }, - "illness_type_7": { - "value": "Mental health", - "hint": "For example, depression, anxiety, schizophrenia or bipolar." - }, - "illness_type_9": { - "value": "Socially or behaviourally", - "hint": "For example, associated with autism spectrum disorder (ASD) which includes Asperger’s or attention deficit hyperactivity disorder (ADHD)." - }, - "illness_type_10": { - "value": "Other" - } - } - } - } - } - } } } }, diff --git a/docs/api/DLUHC-CORE-Data.v1.json b/docs/api/DLUHC-CORE-Data.v1.json index 46443d4c6..308220f9a 100644 --- a/docs/api/DLUHC-CORE-Data.v1.json +++ b/docs/api/DLUHC-CORE-Data.v1.json @@ -261,7 +261,7 @@ "ethnic": "White: English, Welsh, Scottish, Northern Irish or British", "national": "UK national resident in UK", "prevten": "Private sector tenancy", - "armedforces": "A current or former regular in the UK Armed Forces (excluding National Service)", + "armedforces": "Yes, the person is a current or former regular", "ecstat1": "Full-time - 30 hours or more", "other_hhmemb": 7, "relat2": "Partner", diff --git a/spec/factories/case_log.rb b/spec/factories/case_log.rb index 2a481dec1..f5c2963b5 100644 --- a/spec/factories/case_log.rb +++ b/spec/factories/case_log.rb @@ -49,7 +49,7 @@ FactoryBot.define do ecstat2 { "Not seeking work" } homeless { "Other homeless - not found statutorily homeless but considered homeless by landlord" } underoccupation_benefitcap { "No" } - leftreg { "No - they left up to 5 years ago" } + leftreg { "No, they left up to and including 5 years ago" } reservist { "No" } illness { "Yes" } preg_occ { "Yes" } diff --git a/spec/features/form/conditional_questions_spec.rb b/spec/features/form/conditional_questions_spec.rb index d6d679dd4..ab61a2c1b 100644 --- a/spec/features/form/conditional_questions_spec.rb +++ b/spec/features/form/conditional_questions_spec.rb @@ -27,11 +27,11 @@ RSpec.describe "Form Conditional Questions" do it "shows conditional questions if the required answer is selected and hides it again when a different answer option is selected", js: true do visit("/logs/#{id}/armed-forces") # Something about our styling makes the selenium webdriver think the actual radio buttons are not visible so we allow label click here - choose("case-log-armedforces-a-current-or-former-regular-in-the-uk-armed-forces-excluding-national-service-field", allow_label_click: true) + choose("case-log-armedforces-yes-the-person-is-a-current-or-former-regular-field", allow_label_click: true) fill_in("case-log-leftreg-field", with: "text") choose("case-log-armedforces-no-field", allow_label_click: true) expect(page).not_to have_field("case-log-leftreg-field") - choose("case-log-armedforces-a-current-or-former-regular-in-the-uk-armed-forces-excluding-national-service-field", allow_label_click: true) + choose("case-log-armedforces-yes-the-person-is-a-current-or-former-regular-field", allow_label_click: true) expect(page).to have_field("case-log-leftreg-field", with: "") end end diff --git a/spec/fixtures/complete_case_log.json b/spec/fixtures/complete_case_log.json index c5532f1c5..cc734901c 100644 --- a/spec/fixtures/complete_case_log.json +++ b/spec/fixtures/complete_case_log.json @@ -6,8 +6,8 @@ "ethnic": "White: English, Welsh, Scottish, Northern Irish or British", "national": "UK national resident in UK", "prevten": "Private sector tenancy", - "armedforces": "A current or former regular in the UK Armed Forces (excluding National Service)", - "armed_forces": "A current or former regular in the UK Armed Forces (excluding National Service)", + "armedforces": "Yes, the person is a current or former regular", + "armed_forces": "Yes, the person is a current or former regular", "armed_forces_partner": "", "ecstat1": "Full-time - 30 hours or more", "other_hhmemb": 7, @@ -43,7 +43,7 @@ "homeless": "No", "reason": 1, "underoccupation_benefitcap": "No", - "leftreg": "No - they left up to 5 years ago", + "leftreg": "No, they left up to and including 5 years ago", "reservist": "No", "illness": "Yes", "preg_occ": "No", diff --git a/spec/fixtures/forms/2021_2022.json b/spec/fixtures/forms/2021_2022.json index 94f76f963..612bd411d 100644 --- a/spec/fixtures/forms/2021_2022.json +++ b/spec/fixtures/forms/2021_2022.json @@ -156,29 +156,29 @@ "header": "Experience of the UK Armed Forces", "questions": { "armedforces": { - "header": "Is anyone in the household...", - "hint_text": "This excludes national service", + "header": "Does anybody in the household have any links to the UK armed forces?", + "hint_text": "This excludes national service. If there are several people in the household with links to the UK armed forces, you should answer for the regular. If there’s no regular, answer for the reserve. If there’s no reserve, answer for the spouse or civil partner.", "type": "radio", - "check_answer_label": "Armed Forces", + "check_answer_label": "Household links to UK armed forces", "answer_options": { - "0":{ - "value": "A current or former regular in the UK Armed Forces (excluding National Service)" + "0": { + "value": "Yes, the person is a current or former regular" }, "1": { - "value": "A current or former reserve in the UK Armed Forces (excluding National Service)" + "value": "Yes, the person is a current or former reserve" }, "2": { - "value": "A spouse / civil partner of a UK Armed Forces member who has separated or been bereaved within the last 2 years" + "value": "Yes, the tenant is a spouse or civil partner of a UK armed forces member and has been bereaved or separated from them within the last 2 years" }, "3": { "value": "No" }, "4": { - "value": "Tenant prefers not to say" + "value": "Person prefers not to say" } }, "conditional_for": { - "leftreg": ["A current or former regular in the UK Armed Forces (excluding National Service)"] + "leftreg": ["Yes, the person is a current or former regular"] } }, "leftreg": { diff --git a/spec/helpers/conditional_questions_helper_spec.rb b/spec/helpers/conditional_questions_helper_spec.rb index a778eed1e..3f70ec057 100644 --- a/spec/helpers/conditional_questions_helper_spec.rb +++ b/spec/helpers/conditional_questions_helper_spec.rb @@ -14,7 +14,7 @@ RSpec.describe ConditionalQuestionsHelper do describe "find conditional question" do let(:question) { page.questions.find { |q| q.id == "armedforces" } } - let(:answer_value) { "A current or former regular in the UK Armed Forces (excluding National Service)" } + let(:answer_value) { "Yes, the person is a current or former regular" } it "returns the conditional question for a given answer option" do expect(find_conditional_question(page, question, answer_value).id).to eq("leftreg") diff --git a/spec/models/validations/household_validations_spec.rb b/spec/models/validations/household_validations_spec.rb index 801fea796..423b9c412 100644 --- a/spec/models/validations/household_validations_spec.rb +++ b/spec/models/validations/household_validations_spec.rb @@ -122,7 +122,7 @@ RSpec.describe Validations::HouseholdValidations do end it "validates that pregnancy cannot be prefer not to say" do - record.preg_occ = "Prefer not to say" + record.preg_occ = "Tenant prefers not to say" record.sex1 = "Male" household_validator.validate_pregnancy(record) expect(record.errors["preg_occ"]) @@ -244,7 +244,7 @@ RSpec.describe Validations::HouseholdValidations do context "when the tenant prefers not to say if they were or are in the armed forces" do it "validates that injured in the armed forces is not yes" do - record.armedforces = "Tenant prefers not to say" + record.armedforces = "Person prefers not to say" record.reservist = "Yes" household_validator.validate_armed_forces(record) expect(record.errors["reservist"]) @@ -254,7 +254,7 @@ RSpec.describe Validations::HouseholdValidations do context "when the tenant was or is a regular member of the armed forces" do it "expects that injured in the armed forces can be yes" do - record.armedforces = "A current or former regular in the UK Armed Forces (excluding National Service)" + record.armedforces = "Yes, the person is a current or former regular" record.reservist = "Yes" household_validator.validate_armed_forces(record) expect(record.errors["reservist"]).to be_empty @@ -263,7 +263,7 @@ RSpec.describe Validations::HouseholdValidations do context "when the tenant was or is a reserve member of the armed forces" do it "expects that injured in the armed forces can be yes" do - record.armedforces = "A current or former reserve in the UK Armed Forces (excluding National Service)" + record.armedforces = "Yes, the person is a current or former reserve" record.reservist = "Yes" household_validator.validate_armed_forces(record) expect(record.errors["reservist"]).to be_empty @@ -272,7 +272,7 @@ RSpec.describe Validations::HouseholdValidations do context "when the tenant's partner was or is a member of the armed forces" do it "expects that injured in the armed forces can be yes" do - record.armedforces = "A spouse / civil partner of a UK Armed Forces member who has separated or been bereaved within the last 2 years" + record.armedforces = "Yes, the tenant is a spouse or civil partner of a UK armed forces member and has been bereaved or separated from them within the last 2 years" record.reservist = "Yes" household_validator.validate_armed_forces(record) expect(record.errors["reservist"]).to be_empty @@ -289,14 +289,14 @@ RSpec.describe Validations::HouseholdValidations do end it "expects that they served in the armed forces" do - record.armedforces = "A current or former regular in the UK Armed Forces (excluding National Service)" + record.armedforces = "Yes, the person is a current or former regular" record.leftreg = "Yes" household_validator.validate_armed_forces(record) expect(record.errors["leftreg"]).to be_empty end it "expects that they served in the armed forces and may have been injured" do - record.armedforces = "A current or former regular in the UK Armed Forces (excluding National Service)" + record.armedforces = "Yes, the person is a current or former regular" record.leftreg = "Yes" record.reservist = "Yes" household_validator.validate_armed_forces(record)