Browse Source

content updates to form

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

6
app/models/constants/case_log.rb

@ -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,10 +980,10 @@ module Constants::CaseLog
}.freeze
ARMED_FORCES = {
"Yes, the tenant is a current or former regular" => 1,
"Yes, the person is a current or former regular" => 1,
"No" => 2,
"Person prefers not to say" => 3,
"Yes, the tenant is a current or former reserve" => 4,
"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

4
app/models/validations/household_validations.rb

@ -27,13 +27,13 @@ module Validations::HouseholdValidations
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 != "Yes, the tenant is a current or former regular" && 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

21
config/forms/2021_2022.json

@ -2056,18 +2056,18 @@
"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.",
"hint_text": "This excludes national service.<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 tenant is a current or former regular"
"value": "Yes, the person is a current or former regular"
},
"1": {
"value": "Yes, the tenant is a current or former reserve"
"value": "Yes, the person 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"
"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"
@ -2084,7 +2084,7 @@
"description": "",
"depends_on": [
{
"armedforces": "Yes, the tenant is a current or former regular"
"armedforces": "Yes, the person is a current or former regular"
}
],
"questions": {
@ -2111,14 +2111,14 @@
}
},
"armed_forces_reservist": {
"header": "Experience of the UK Armed Forces",
"header": "",
"description": "",
"depends_on": [
{
"armedforces": "Yes, the tenant is a current or former regular"
"armedforces": "Yes, the person is a current or former regular"
},
{
"armedforces": "Yes, the tenant is a current or former reserve"
"armedforces": "Yes, the person is a current or former reserve"
}
],
"questions": {
@ -2157,11 +2157,8 @@
"1": {
"value": "No"
},
"divider": {
"value": true
},
"2": {
"value": "Prefer not to say"
"value": "Tenant prefers not to say"
}
}
}

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": "Yes, the tenant is a current or former regular",
"armedforces": "Yes, the person 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": "Yes, the tenant is a current or former regular",
"armed_forces": "Yes, the tenant is a current or former regular",
"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,

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

@ -162,10 +162,10 @@
"check_answer_label": "Household links to UK armed forces",
"answer_options": {
"0": {
"value": "Yes, the tenant is a current or former regular"
"value": "Yes, the person is a current or former regular"
},
"1": {
"value": "Yes, the tenant is a current or former reserve"
"value": "Yes, the person 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"
@ -178,7 +178,7 @@
}
},
"conditional_for": {
"leftreg": ["Yes, the tenant is a current or former regular"]
"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) { "Yes, the tenant is a current or former regular" }
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")

10
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"])
@ -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 = "Yes, the tenant is a current or former regular"
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 = "Yes, the tenant is a current or former reserve"
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
@ -289,14 +289,14 @@ RSpec.describe Validations::HouseholdValidations do
end
it "expects that they served in the armed forces" do
record.armedforces = "Yes, the tenant is a current or former regular"
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 = "Yes, the tenant is a current or former regular"
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