Browse Source

spec fixes

pull/311/head
MadeTech Dushan 3 years ago
parent
commit
7a66bb3888
  1. 4
      app/models/validations/household_validations.rb
  2. 480
      config/forms/2021_2022.json
  3. 2
      docs/api/DLUHC-CORE-Data.v1.json
  4. 4
      spec/fixtures/complete_case_log.json
  5. 2
      spec/fixtures/forms/2021_2022.json
  6. 2
      spec/helpers/conditional_questions_helper_spec.rb
  7. 6
      spec/models/validations/household_validations_spec.rb

4
app/models/validations/household_validations.rb

@ -24,10 +24,10 @@ 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 tenant is a current or former regular" && record.leftreg.present?
record.errors.add :leftreg, I18n.t("validations.household.leftreg.question_not_required")
end
end

480
config/forms/2021_2022.json

@ -2042,6 +2042,246 @@
}
}
},
"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 tenant is a current or former regular"
},
"1": {
"value": "Yes, the tenant is a current or former reserve"
},
"2": {
"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": "Person prefers not to say"
}
}
}
}
},
"armed_forces_member": {
"header": "",
"description": "",
"depends_on": [
{
"armedforces": "Yes, the tenant 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": "Experience of the UK Armed Forces",
"description": "",
"depends_on": [
{
"armedforces": "Yes, the tenant is a current or former regular"
},
{
"armedforces": "Yes, the tenant 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"
},
"divider": {
"value": true
},
"2": {
"value": "Prefer not to say"
}
}
}
}
},
"accessibility_requirements": {
"header": "",
"description": "",
"questions": {
"accessibility_requirements": {
"header": "Does anybody in the household have any disabled access needs?",
"hint_text": "Select all that apply.",
"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,246 +3456,6 @@
]
}
}
},
"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 tenant is a current or former regular"
},
"1": {
"value": "Yes, the tenant is a current or former reserve"
},
"2": {
"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": "Person prefers not to say"
}
}
}
}
},
"armed_forces_member": {
"header": "",
"description": "",
"depends_on": [
{
"armedforces": "Yes, the tenant 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": "Experience of the UK Armed Forces",
"description": "",
"depends_on": [
{
"armedforces": "Yes, the tenant is a current or former regular"
},
{
"armedforces": "Yes, the tenant 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"
},
"divider": {
"value": true
},
"2": {
"value": "Prefer not to say"
}
}
}
}
},
"accessibility_requirements": {
"header": "",
"description": "",
"questions": {
"accessibility_requirements": {
"header": "Does anybody in the household have any disabled access needs?",
"hint_text": "Select all that apply.",
"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"
}
}
}
}
}
}
}
}
},

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 tenant is a current or former regular",
"ecstat1": "Full-time - 30 hours or more",
"other_hhmemb": 7,
"relat2": "Partner",

4
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 tenant is a current or former regular",
"armed_forces": "Yes, the tenant is a current or former regular",
"armed_forces_partner": "",
"ecstat1": "Full-time - 30 hours or more",
"other_hhmemb": 7,

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

@ -178,7 +178,7 @@
}
},
"conditional_for": {
"leftreg": ["A current or former regular in the UK Armed Forces (excluding National Service)"]
"leftreg": ["Yes, the tenant 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 tenant 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")

6
spec/models/validations/household_validations_spec.rb

@ -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 tenant is a current or former regular"
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 tenant 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 tenant is a current or former regular"
record.leftreg = "Yes"
record.reservist = "Yes"
household_validator.validate_armed_forces(record)

Loading…
Cancel
Save