Browse Source

Household situation content (#327)

* update content

* add a different error message for homeless validation
pull/329/head
kosiakkatrina 3 years ago committed by GitHub
parent
commit
0a235dbc69
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      app/models/validations/household_validations.rb
  2. 8
      config/forms/2021_2022.json
  3. 2
      config/locales/en.yml
  4. 2
      spec/models/validations/household_validations_spec.rb

2
app/models/validations/household_validations.rb

@ -7,7 +7,7 @@ module Validations::HouseholdValidations
def validate_reasonable_preference(record) def validate_reasonable_preference(record)
if record.homeless == "No" && record.reasonpref == "Yes" if record.homeless == "No" && record.reasonpref == "Yes"
record.errors.add :reasonpref, I18n.t("validations.household.reasonpref.not_homeless") record.errors.add :reasonpref, I18n.t("validations.household.reasonpref.not_homeless")
record.errors.add :homeless, I18n.t("validations.household.reasonpref.not_homeless") record.errors.add :homeless, I18n.t("validations.household.homeless.reasonpref.not_homeless")
elsif record.reasonpref == "No" elsif record.reasonpref == "No"
if [record.rp_homeless, record.rp_insan_unsat, record.rp_medwel, record.rp_hardship, record.rp_dontknow].any? { |a| a == "Yes" } if [record.rp_homeless, record.rp_insan_unsat, record.rp_medwel, record.rp_hardship, record.rp_dontknow].any? { |a| a == "Yes" }
record.errors.add :reasonable_preference_reason, I18n.t("validations.household.reasonable_preference_reason.reason_not_required") record.errors.add :reasonable_preference_reason, I18n.t("validations.household.reasonable_preference_reason.reason_not_required")

8
config/forms/2021_2022.json

@ -2135,7 +2135,7 @@
"depends_on": [{ "renewal": "No" }] "depends_on": [{ "renewal": "No" }]
}, },
"reason_for_leaving_last_settled_home": { "reason_for_leaving_last_settled_home": {
"header": "Leaving their last settled home", "header": "",
"description": "", "description": "",
"questions": { "questions": {
"reason": { "reason": {
@ -2263,7 +2263,7 @@
"depends_on": [{ "renewal": "No" }] "depends_on": [{ "renewal": "No" }]
}, },
"reason_for_leaving_last_settled_home_renewal": { "reason_for_leaving_last_settled_home_renewal": {
"header": "Leaving their last settled home", "header": "",
"description": "", "description": "",
"questions": { "questions": {
"reason": { "reason": {
@ -2922,13 +2922,13 @@
} }
}, },
"reasonable_preference_reason": { "reasonable_preference_reason": {
"header": "Reason for reasonable preference being given", "header": "",
"description": "", "description": "",
"questions": { "questions": {
"reasonable_preference_reason": { "reasonable_preference_reason": {
"check_answer_label": "Reason for reasonable preference", "check_answer_label": "Reason for reasonable preference",
"header": "Why was the household given ‘reasonable preference’?", "header": "Why was the household given ‘reasonable preference’?",
"hint_text": "", "hint_text": "Select all that apply",
"type": "checkbox", "type": "checkbox",
"answer_options": { "answer_options": {
"rp_homeless": { "rp_homeless": {

2
config/locales/en.yml

@ -121,6 +121,8 @@ en:
internal_transfer: "Answer cannot be assessed as homeless as you already told us this tenancy is an internal transfer" internal_transfer: "Answer cannot be assessed as homeless as you already told us this tenancy is an internal transfer"
other: other:
internal_transfer: "Answer cannot be other homelessness as you already told us this tenancy was an internal transfer" internal_transfer: "Answer cannot be other homelessness as you already told us this tenancy was an internal transfer"
reasonpref:
not_homeless: "Can not be No if household was given reasonable preference"
tenancy: tenancy:

2
spec/models/validations/household_validations_spec.rb

@ -72,7 +72,7 @@ RSpec.describe Validations::HouseholdValidations do
expect(record.errors["reasonpref"]) expect(record.errors["reasonpref"])
.to include(match I18n.t("validations.household.reasonpref.not_homeless")) .to include(match I18n.t("validations.household.reasonpref.not_homeless"))
expect(record.errors["homeless"]) expect(record.errors["homeless"])
.to include(match I18n.t("validations.household.reasonpref.not_homeless")) .to include(match I18n.t("validations.household.homeless.reasonpref.not_homeless"))
end end
end end

Loading…
Cancel
Save