Browse Source

Update renewal reason BU validation (#2298)

pull/2278/head^2
kosiakkatrina 10 months ago committed by GitHub
parent
commit
09fb0bfd11
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 4
      app/services/bulk_upload/lettings/year2024/row_parser.rb
  2. 1
      config/locales/en.yml
  3. 28
      spec/services/bulk_upload/lettings/year2024/row_parser_spec.rb

4
app/services/bulk_upload/lettings/year2024/row_parser.rb

@ -672,8 +672,8 @@ private
end end
def validate_leaving_reason_for_renewal def validate_leaving_reason_for_renewal
if field_7 == 1 && ![40, 42].include?(field_98) if field_7 == 1 && ![50, 51, 52, 53].include?(field_98)
errors.add(:field_98, I18n.t("validations.household.reason.renewal_reason_needed")) errors.add(:field_98, I18n.t("validations.household.reason.renewal_reason_needed_2024"))
end end
end end

1
config/locales/en.yml

@ -544,6 +544,7 @@ en:
reason: reason:
not_internal_transfer: "Answer cannot be ‘permanently decanted from another property owned by this landlord’ as you told us the source of referral for this tenancy was not an internal transfer" not_internal_transfer: "Answer cannot be ‘permanently decanted from another property owned by this landlord’ as you told us the source of referral for this tenancy was not an internal transfer"
renewal_reason_needed: 'The reason for leaving must be "End of assured shorthold tenancy - no fault" or "End of fixed term tenancy - no fault" if the letting is a renewal' renewal_reason_needed: 'The reason for leaving must be "End of assured shorthold tenancy - no fault" or "End of fixed term tenancy - no fault" if the letting is a renewal'
renewal_reason_needed_2024: 'The reason for leaving must be "End of social housing tenancy - no fault", "End of social housing tenancy - evicted due to anti-social behaviour (ASB)", "End of social housing tenancy - evicted due to rent arrears" or "End of social housing tenancy - evicted for any other reason"'
other_not_settled: "Please give the reason for the tenant leaving their last settled home. This is where they were living before they became homeless, were living in temporary accommodation or sleeping rough" other_not_settled: "Please give the reason for the tenant leaving their last settled home. This is where they were living before they became homeless, were living in temporary accommodation or sleeping rough"
condition_effects: condition_effects:
no_choices: "You cannot answer this question as you told us nobody in the household has a physical or mental health condition (or other illness) expected to last 12 months or more" no_choices: "You cannot answer this question as you told us nobody in the household has a physical or mental health condition (or other illness) expected to last 12 months or more"

28
spec/services/bulk_upload/lettings/year2024/row_parser_spec.rb

@ -976,27 +976,43 @@ RSpec.describe BulkUpload::Lettings::Year2024::RowParser do
describe "#field_98" do # leaving reason describe "#field_98" do # leaving reason
context "when field_7 is 1 meaning it is a renewal" do context "when field_7 is 1 meaning it is a renewal" do
context "when field_98 is 40" do context "when field_98 is 50" do
let(:attributes) { { bulk_upload:, field_98: "40", field_7: "1" } } let(:attributes) { { bulk_upload:, field_98: "50", field_7: "1" } }
it "is permitted" do it "is permitted" do
expect(parser.errors[:field_98]).to be_blank expect(parser.errors[:field_98]).to be_blank
end end
end end
context "when field_98 is 42" do context "when field_98 is 51" do
let(:attributes) { { bulk_upload:, field_98: "42", field_7: "1" } } let(:attributes) { { bulk_upload:, field_98: "51", field_7: "1" } }
it "is permitted" do it "is permitted" do
expect(parser.errors[:field_98]).to be_blank expect(parser.errors[:field_98]).to be_blank
end end
end end
context "when field_98 is not 40 or 42" do context "when field_98 is 52" do
let(:attributes) { { bulk_upload:, field_98: "52", field_7: "1" } }
it "is permitted" do
expect(parser.errors[:field_98]).to be_blank
end
end
context "when field_98 is 53" do
let(:attributes) { { bulk_upload:, field_98: "53", field_7: "1" } }
it "is permitted" do
expect(parser.errors[:field_98]).to be_blank
end
end
context "when field_98 is not 50, 51, 52 or 53" do
let(:attributes) { { bulk_upload:, field_98: "1", field_7: "1" } } let(:attributes) { { bulk_upload:, field_98: "1", field_7: "1" } }
it "is not permitted" do it "is not permitted" do
expect(parser.errors[:field_98]).to be_present expect(parser.errors[:field_98]).to include('The reason for leaving must be "End of social housing tenancy - no fault", "End of social housing tenancy - evicted due to anti-social behaviour (ASB)", "End of social housing tenancy - evicted due to rent arrears" or "End of social housing tenancy - evicted for any other reason"')
end end
end end
end end

Loading…
Cancel
Save