From e53820a517defca858eb175f67da4fe1b0132acf Mon Sep 17 00:00:00 2001 From: Phil Lee Date: Tue, 14 Feb 2023 10:38:06 +0000 Subject: [PATCH] add bulk upload validation - no disabled needs cannot be selected in conjunction with a disabled need --- app/services/bulk_upload/lettings/row_parser.rb | 7 +++++++ config/locales/en.yml | 2 ++ spec/services/bulk_upload/lettings/row_parser_spec.rb | 10 ++++++++++ 3 files changed, 19 insertions(+) diff --git a/app/services/bulk_upload/lettings/row_parser.rb b/app/services/bulk_upload/lettings/row_parser.rb index 96b047d4f..819658465 100644 --- a/app/services/bulk_upload/lettings/row_parser.rb +++ b/app/services/bulk_upload/lettings/row_parser.rb @@ -151,6 +151,7 @@ class BulkUpload::Lettings::RowParser validate :validate_leaving_reason_for_renewal validate :validate_lettings_type_matches_bulk_upload validate :validate_only_one_housing_needs_type + validate :validate_no_disabled_needs_conjunction def valid? errors.clear @@ -179,6 +180,12 @@ class BulkUpload::Lettings::RowParser private + def validate_no_disabled_needs_conjunction + if field_59 == 1 && [field_55, field_56, field_57, field_58].compact.count.positive? + errors.add(:field_59, I18n.t("validations.household.housingneeds.validate_no_disabled_needs_conjunction")) + end + end + def validate_only_one_housing_needs_type if [field_55, field_56, field_57].compact.count.positive? errors.add(:field_55, I18n.t("validations.household.housingneeds_type.only_one_option_permitted")) diff --git a/config/locales/en.yml b/config/locales/en.yml index c37ee8aa2..0e93c6342 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -346,6 +346,8 @@ en: one_or_two_choices: "You can only select one option or ‘other disabled access needs’ plus ‘wheelchair-accessible housing’, ‘wheelchair access to essential rooms’ or ‘level access housing’" housingneeds_type: only_one_option_permitted: "Only one disabled access need: fully wheelchair-accessible housing, wheelchair access to essential rooms or level access housing, can be selected" + housingneeds: + validate_no_disabled_needs_conjunction: "No disabled needs can’t be selected if you have selected fully wheelchair-accessible housing, wheelchair access to essential rooms, level access housing or other disabled access needs" prevten: non_temp_accommodation: "Answer cannot be non-temporary accommodation as this is a re-let to a tenant who occupied the same property as temporary accommodation" over_20_foster_care: "Answer cannot be a children’s home or foster care as the lead tenant is 20 or older" diff --git a/spec/services/bulk_upload/lettings/row_parser_spec.rb b/spec/services/bulk_upload/lettings/row_parser_spec.rb index d2183af37..589301439 100644 --- a/spec/services/bulk_upload/lettings/row_parser_spec.rb +++ b/spec/services/bulk_upload/lettings/row_parser_spec.rb @@ -356,6 +356,16 @@ RSpec.describe BulkUpload::Lettings::RowParser do end end + describe "#field_59" do + context "when 1 and another disability field selected" do + let(:attributes) { { bulk_upload:, field_59: "1", field_58: "1" } } + + it "is not permitted" do + expect(parser.errors[:field_59]).to be_present + end + end + end + describe "#field_78" do # referral context "when 3 ie PRP nominated by LA and owning org is LA" do let(:attributes) { { bulk_upload:, field_78: "3", field_111: owning_org.old_visible_id } }