From 09fb0bfd11e931e5457cefffcc3b4b887de26124 Mon Sep 17 00:00:00 2001 From: kosiakkatrina <54268893+kosiakkatrina@users.noreply.github.com> Date: Wed, 13 Mar 2024 08:05:39 +0000 Subject: [PATCH] Update renewal reason BU validation (#2298) --- .../lettings/year2024/row_parser.rb | 4 +-- config/locales/en.yml | 1 + .../lettings/year2024/row_parser_spec.rb | 28 +++++++++++++++---- 3 files changed, 25 insertions(+), 8 deletions(-) diff --git a/app/services/bulk_upload/lettings/year2024/row_parser.rb b/app/services/bulk_upload/lettings/year2024/row_parser.rb index 6ba9ab69a..ba19acb8c 100644 --- a/app/services/bulk_upload/lettings/year2024/row_parser.rb +++ b/app/services/bulk_upload/lettings/year2024/row_parser.rb @@ -672,8 +672,8 @@ private end def validate_leaving_reason_for_renewal - if field_7 == 1 && ![40, 42].include?(field_98) - errors.add(:field_98, I18n.t("validations.household.reason.renewal_reason_needed")) + if field_7 == 1 && ![50, 51, 52, 53].include?(field_98) + errors.add(:field_98, I18n.t("validations.household.reason.renewal_reason_needed_2024")) end end diff --git a/config/locales/en.yml b/config/locales/en.yml index 9238347f8..655723e58 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -544,6 +544,7 @@ en: 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" 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" 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" diff --git a/spec/services/bulk_upload/lettings/year2024/row_parser_spec.rb b/spec/services/bulk_upload/lettings/year2024/row_parser_spec.rb index 73e639449..7b15d4381 100644 --- a/spec/services/bulk_upload/lettings/year2024/row_parser_spec.rb +++ b/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 context "when field_7 is 1 meaning it is a renewal" do - context "when field_98 is 40" do - let(:attributes) { { bulk_upload:, field_98: "40", field_7: "1" } } + context "when field_98 is 50" do + let(:attributes) { { bulk_upload:, field_98: "50", field_7: "1" } } it "is permitted" do expect(parser.errors[:field_98]).to be_blank end end - context "when field_98 is 42" do - let(:attributes) { { bulk_upload:, field_98: "42", field_7: "1" } } + context "when field_98 is 51" do + let(:attributes) { { bulk_upload:, field_98: "51", field_7: "1" } } it "is permitted" do expect(parser.errors[:field_98]).to be_blank 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" } } 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