Browse Source

Update more reasonpref values and error message content (#346)

pull/347/head
kosiakkatrina 3 years ago committed by GitHub
parent
commit
526553d2cd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      app/models/case_log.rb
  2. 12
      app/models/form/question.rb
  3. 4
      config/locales/en.yml
  4. 2
      spec/factories/case_log.rb
  5. 2
      spec/fixtures/exports/case_logs.xml
  6. 6
      spec/models/case_log_spec.rb
  7. 4
      spec/models/validations/household_validations_spec.rb

2
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?

12
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],

4
config/locales/en.yml

@ -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"

2
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 }

2
spec/fixtures/exports/case_logs.xml vendored

@ -58,7 +58,7 @@
<layear>2</layear>
<lawaitlist>1</lawaitlist>
<property_postcode>NW1 5TY</property_postcode>
<reasonpref>0</reasonpref>
<reasonpref>1</reasonpref>
<cbl>1</cbl>
<chr>1</chr>
<cap>0</cap>

6
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]

4
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"])

Loading…
Cancel
Save