From 526553d2cdd799c53dc4115b69ba4e79fde24377 Mon Sep 17 00:00:00 2001
From: kosiakkatrina <54268893+kosiakkatrina@users.noreply.github.com>
Date: Wed, 2 Mar 2022 11:30:07 +0000
Subject: [PATCH] Update more reasonpref values and error message content
(#346)
---
app/models/case_log.rb | 2 +-
app/models/form/question.rb | 12 ++++++------
config/locales/en.yml | 6 +++---
spec/factories/case_log.rb | 2 +-
spec/fixtures/exports/case_logs.xml | 2 +-
spec/models/case_log_spec.rb | 6 +++---
.../models/validations/household_validations_spec.rb | 4 ++--
7 files changed, 17 insertions(+), 17 deletions(-)
diff --git a/app/models/case_log.rb b/app/models/case_log.rb
index cffefbe73..9d84e877a 100644
--- a/app/models/case_log.rb
+++ b/app/models/case_log.rb
@@ -112,7 +112,7 @@ class CaseLog < ApplicationRecord
end
def given_reasonable_preference?
- !!(reasonpref && reasonpref.zero?)
+ reasonpref == 1
end
def is_renewal?
diff --git a/app/models/form/question.rb b/app/models/form/question.rb
index 4a045b27e..670ca9a3b 100644
--- a/app/models/form/question.rb
+++ b/app/models/form/question.rb
@@ -223,8 +223,8 @@ private
reservist: [0],
preg_occ: [0],
illness: [0],
- underoccupation_benefitcap: [0, 1, 2],
- reasonpref: [0],
+ underoccupation_benefitcap: [4, 5, 6],
+ reasonpref: [1],
net_income_known: [0],
household_charge: [0],
is_carehome: [1],
@@ -247,8 +247,8 @@ private
reservist: [1],
preg_occ: [1],
illness: [1],
- underoccupation_benefitcap: [3],
- reasonpref: [1],
+ underoccupation_benefitcap: [2],
+ reasonpref: [2],
net_income_known: [1],
household_charge: [1],
is_carehome: [0],
@@ -257,8 +257,8 @@ private
RADIO_DONT_KNOW_VALUE = {
letting_in_sheltered_accommodation: [3],
- underoccupation_benefitcap: [4],
- reasonpref: [2],
+ underoccupation_benefitcap: [3],
+ reasonpref: [3],
rent_shortfall: [1],
layear: [7],
reason_for_leaving_last_settled_home: [32],
diff --git a/config/locales/en.yml b/config/locales/en.yml
index cada5a023..f0b3b8020 100644
--- a/config/locales/en.yml
+++ b/config/locales/en.yml
@@ -74,7 +74,7 @@ en:
tshortfall:
outstanding_amount_not_required: "You must not answer the outstanding amount question if you don’t have outstanding rent or charges."
hbrentshortfall:
- outstanding_no_benefits: "Outstanding amount for basic rent and/or benefit eligible charges can not be 'Yes' if tenant is not in receipt of housing benefit or universal benefit or if benefit is unknown"
+ outstanding_no_benefits: "Outstanding amount for basic rent and/or benefit eligible charges cannot be 'Yes' if tenant is not in receipt of housing benefit or universal benefit or if benefit is unknown"
benefits:
part_or_full_time: "income is from Universal Credit, state pensions or benefits cannot be All if the tenant or the partner works part or full time"
earnings:
@@ -86,7 +86,7 @@ en:
household:
reasonpref:
- not_homeless: "Can not be \"They were homeless or about to lose their home\" if Not Homeless immediately prior to this letting has been selected"
+ not_homeless: "Answer cannot be ‘homeless or about to lose their home’ as you already told us the tenant was not homeless immediately prior to this letting"
reasonable_preference_reason:
reason_required: "If reasonable preference is \"Yes\", a reason must be given"
reason_not_required: "If reasonable preference is \"No\", no reasons should be given"
@@ -127,7 +127,7 @@ en:
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 \"They were homeless or about to lose their home\" was selected as reasonable preference reason"
+ not_homeless: "Answer cannot be ‘no’ as you already told us the tenant was homeless or about to lose their home"
previous_la_known: "Enter a local authority"
diff --git a/spec/factories/case_log.rb b/spec/factories/case_log.rb
index c94148a0c..b5de2432e 100644
--- a/spec/factories/case_log.rb
+++ b/spec/factories/case_log.rb
@@ -77,7 +77,7 @@ FactoryBot.define do
layear { 2 }
lawaitlist { 1 }
property_postcode { "NW1 5TY" }
- reasonpref { 0 }
+ reasonpref { 1 }
cbl { 1 }
chr { 1 }
cap { 0 }
diff --git a/spec/fixtures/exports/case_logs.xml b/spec/fixtures/exports/case_logs.xml
index d3e18f1c0..80ed8a9db 100644
--- a/spec/fixtures/exports/case_logs.xml
+++ b/spec/fixtures/exports/case_logs.xml
@@ -58,7 +58,7 @@
2
1
NW1 5TY
- 0
+ 1
1
1
0
diff --git a/spec/models/case_log_spec.rb b/spec/models/case_log_spec.rb
index 04f9efe51..79ffa5eb6 100644
--- a/spec/models/case_log_spec.rb
+++ b/spec/models/case_log_spec.rb
@@ -657,10 +657,10 @@ RSpec.describe CaseLog do
end
it "correctly derives and saves reasonpref when changed to renewal" do
- case_log.update!({ reasonpref: 0 })
+ case_log.update!({ reasonpref: 1 })
record_from_db = ActiveRecord::Base.connection.execute("select reasonpref from case_logs where id=#{case_log.id}").to_a[0]
- expect(record_from_db["reasonpref"]).to eq(0)
- expect(case_log["reasonpref"]).to eq(0)
+ expect(record_from_db["reasonpref"]).to eq(1)
+ expect(case_log["reasonpref"]).to eq(1)
case_log.update!({ renewal: 1 })
record_from_db = ActiveRecord::Base.connection.execute("select reasonpref from case_logs where id=#{case_log.id}").to_a[0]
diff --git a/spec/models/validations/household_validations_spec.rb b/spec/models/validations/household_validations_spec.rb
index 88b54832d..19c524c8d 100644
--- a/spec/models/validations/household_validations_spec.rb
+++ b/spec/models/validations/household_validations_spec.rb
@@ -80,7 +80,7 @@ RSpec.describe Validations::HouseholdValidations do
context "when the tenant was previously homeless" do
it "does not add an error" do
record.homeless = 1
- record.reasonpref = 0
+ record.reasonpref = 1
household_validator.validate_reasonable_preference(record)
expect(record.errors["reasonpref"]).to be_empty
expect(record.errors["homeless"]).to be_empty
@@ -102,7 +102,7 @@ RSpec.describe Validations::HouseholdValidations do
end
it "validates that no reason is given" do
- record.reasonpref = 1
+ record.reasonpref = 2
record.rp_medwel = 1
household_validator.validate_reasonable_preference(record)
expect(record.errors["reasonable_preference_reason"])