Browse Source

reason_for_leaving_last_settled_home validation added

pull/59/head
Matthew Phelan 3 years ago
parent
commit
6204088f48
  1. 6
      app/models/case_log.rb
  2. 2
      config/forms/2021_2022.json
  3. 2
      db/schema.rb

6
app/models/case_log.rb

@ -38,6 +38,12 @@ class CaseLogValidator < ActiveModel::Validator
record.errors.add :other_reason_for_leaving_last_settled_home, "The other reason must not be provided if the reason for leaving settled home was not other" record.errors.add :other_reason_for_leaving_last_settled_home, "The other reason must not be provided if the reason for leaving settled home was not other"
end end
end end
def validate_reason_for_leaving_last_settled_home(record)
if record.reason_for_leaving_last_settled_home == "Do not know" && record.benefit_cap_spare_room_subsidy != "Do not know"
record.errors.add :benefit_cap_spare_room_subsidy, "must be do not know if tenant’s main reason for leaving is do not know"
end
end
def validate(record) def validate(record)
# If we've come from the form UI we only want to validate the specific fields # If we've come from the form UI we only want to validate the specific fields

2
config/forms/2021_2022.json

@ -612,7 +612,7 @@
"header": "Leaving their last settled home", "header": "Leaving their last settled home",
"description": "", "description": "",
"questions": { "questions": {
"last_settled_home": { "reason_for_leaving_last_settled_home": {
"header": "What is the tenant’s main reason for leaving?", "header": "What is the tenant’s main reason for leaving?",
"hint_text": "", "hint_text": "",
"type": "radio", "type": "radio",

2
db/schema.rb

@ -130,8 +130,8 @@ ActiveRecord::Schema.define(version: 2021_10_15_090040) do
t.boolean "reasonable_preference_reason_medical_grounds" t.boolean "reasonable_preference_reason_medical_grounds"
t.boolean "reasonable_preference_reason_avoid_hardship" t.boolean "reasonable_preference_reason_avoid_hardship"
t.boolean "reasonable_preference_reason_do_not_know" t.boolean "reasonable_preference_reason_do_not_know"
t.datetime "discarded_at"
t.integer "property_number_of_times_relet" t.integer "property_number_of_times_relet"
t.datetime "discarded_at"
t.index ["discarded_at"], name: "index_case_logs_on_discarded_at" t.index ["discarded_at"], name: "index_case_logs_on_discarded_at"
end end

Loading…
Cancel
Save