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. 6
      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 end
def given_reasonable_preference? def given_reasonable_preference?
!!(reasonpref && reasonpref.zero?) reasonpref == 1
end end
def is_renewal? def is_renewal?

12
app/models/form/question.rb

@ -223,8 +223,8 @@ private
reservist: [0], reservist: [0],
preg_occ: [0], preg_occ: [0],
illness: [0], illness: [0],
underoccupation_benefitcap: [0, 1, 2], underoccupation_benefitcap: [4, 5, 6],
reasonpref: [0], reasonpref: [1],
net_income_known: [0], net_income_known: [0],
household_charge: [0], household_charge: [0],
is_carehome: [1], is_carehome: [1],
@ -247,8 +247,8 @@ private
reservist: [1], reservist: [1],
preg_occ: [1], preg_occ: [1],
illness: [1], illness: [1],
underoccupation_benefitcap: [3], underoccupation_benefitcap: [2],
reasonpref: [1], reasonpref: [2],
net_income_known: [1], net_income_known: [1],
household_charge: [1], household_charge: [1],
is_carehome: [0], is_carehome: [0],
@ -257,8 +257,8 @@ private
RADIO_DONT_KNOW_VALUE = { RADIO_DONT_KNOW_VALUE = {
letting_in_sheltered_accommodation: [3], letting_in_sheltered_accommodation: [3],
underoccupation_benefitcap: [4], underoccupation_benefitcap: [3],
reasonpref: [2], reasonpref: [3],
rent_shortfall: [1], rent_shortfall: [1],
layear: [7], layear: [7],
reason_for_leaving_last_settled_home: [32], reason_for_leaving_last_settled_home: [32],

6
config/locales/en.yml

@ -74,7 +74,7 @@ en:
tshortfall: tshortfall:
outstanding_amount_not_required: "You must not answer the outstanding amount question if you don’t have outstanding rent or charges." outstanding_amount_not_required: "You must not answer the outstanding amount question if you don’t have outstanding rent or charges."
hbrentshortfall: 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: 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" 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: earnings:
@ -86,7 +86,7 @@ en:
household: household:
reasonpref: 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: reasonable_preference_reason:
reason_required: "If reasonable preference is \"Yes\", a reason must be given" 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" reason_not_required: "If reasonable preference is \"No\", no reasons should be given"
@ -127,7 +127,7 @@ en:
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: 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" previous_la_known: "Enter a local authority"

2
spec/factories/case_log.rb

@ -77,7 +77,7 @@ FactoryBot.define do
layear { 2 } layear { 2 }
lawaitlist { 1 } lawaitlist { 1 }
property_postcode { "NW1 5TY" } property_postcode { "NW1 5TY" }
reasonpref { 0 } reasonpref { 1 }
cbl { 1 } cbl { 1 }
chr { 1 } chr { 1 }
cap { 0 } cap { 0 }

2
spec/fixtures/exports/case_logs.xml vendored

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

6
spec/models/case_log_spec.rb

@ -657,10 +657,10 @@ RSpec.describe CaseLog do
end end
it "correctly derives and saves reasonpref when changed to renewal" do 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] 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(record_from_db["reasonpref"]).to eq(1)
expect(case_log["reasonpref"]).to eq(0) expect(case_log["reasonpref"]).to eq(1)
case_log.update!({ renewal: 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] 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 context "when the tenant was previously homeless" do
it "does not add an error" do it "does not add an error" do
record.homeless = 1 record.homeless = 1
record.reasonpref = 0 record.reasonpref = 1
household_validator.validate_reasonable_preference(record) household_validator.validate_reasonable_preference(record)
expect(record.errors["reasonpref"]).to be_empty expect(record.errors["reasonpref"]).to be_empty
expect(record.errors["homeless"]).to be_empty expect(record.errors["homeless"]).to be_empty
@ -102,7 +102,7 @@ RSpec.describe Validations::HouseholdValidations do
end end
it "validates that no reason is given" do it "validates that no reason is given" do
record.reasonpref = 1 record.reasonpref = 2
record.rp_medwel = 1 record.rp_medwel = 1
household_validator.validate_reasonable_preference(record) household_validator.validate_reasonable_preference(record)
expect(record.errors["reasonable_preference_reason"]) expect(record.errors["reasonable_preference_reason"])

Loading…
Cancel
Save