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)
if record.homeless == "No" && record.reasonpref == "Yes"
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"
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")

8
config/forms/2021_2022.json

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

2
spec/models/validations/household_validations_spec.rb

@ -72,7 +72,7 @@ RSpec.describe Validations::HouseholdValidations do
expect(record.errors["reasonpref"])
.to include(match I18n.t("validations.household.reasonpref.not_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

Loading…
Cancel
Save