Browse Source

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 <paulrobertlloyd@users.noreply.github.com>

Co-authored-by: Paul Robert Lloyd <paulrobertlloyd@users.noreply.github.com>
pull/329/head
Dushan 3 years ago committed by GitHub
parent
commit
aea12947eb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 16
      app/models/constants/case_log.rb
  2. 6
      app/models/validations/household_validations.rb
  3. 470
      config/forms/2021_2022.json
  4. 2
      docs/api/DLUHC-CORE-Data.v1.json
  5. 2
      spec/factories/case_log.rb
  6. 4
      spec/features/form/conditional_questions_spec.rb
  7. 6
      spec/fixtures/complete_case_log.json
  8. 16
      spec/fixtures/forms/2021_2022.json
  9. 2
      spec/helpers/conditional_questions_helper_spec.rb
  10. 14
      spec/models/validations/household_validations_spec.rb

16
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 = {

6
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

470
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.<br><br>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:<ul><li>Physical Condition</li><li>Mental Health Condition</li><li>Other Illness</li></ul>",
"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"
}
}
}
}
}
}
}
}
},

2
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",

2
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" }

4
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

6
spec/fixtures/complete_case_log.json vendored

@ -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",

16
spec/fixtures/forms/2021_2022.json vendored

@ -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)"
"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": {

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

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

Loading…
Cancel
Save