From 8ffd798cf62c25e2b91bfc5573752a22ad7132d9 Mon Sep 17 00:00:00 2001 From: Phil Lee Date: Tue, 14 Feb 2023 10:57:42 +0000 Subject: [PATCH] add bulk upload validation - dont know disabled needs cannot be selected in conjunction with a disabled need --- app/services/bulk_upload/lettings/row_parser.rb | 9 ++++++++- config/locales/en.yml | 3 ++- spec/services/bulk_upload/lettings/row_parser_spec.rb | 10 ++++++++++ 3 files changed, 20 insertions(+), 2 deletions(-) diff --git a/app/services/bulk_upload/lettings/row_parser.rb b/app/services/bulk_upload/lettings/row_parser.rb index 819658465..ff93e3b8b 100644 --- a/app/services/bulk_upload/lettings/row_parser.rb +++ b/app/services/bulk_upload/lettings/row_parser.rb @@ -152,6 +152,7 @@ class BulkUpload::Lettings::RowParser validate :validate_lettings_type_matches_bulk_upload validate :validate_only_one_housing_needs_type validate :validate_no_disabled_needs_conjunction + validate :validate_dont_know_disabled_needs_conjunction def valid? errors.clear @@ -180,9 +181,15 @@ class BulkUpload::Lettings::RowParser private + def validate_dont_know_disabled_needs_conjunction + if field_60 == 1 && [field_55, field_56, field_57, field_58].compact.count.positive? + errors.add(:field_60, I18n.t("validations.household.housingneeds.dont_know_disabled_needs_conjunction")) + end + end + 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")) + errors.add(:field_59, I18n.t("validations.household.housingneeds.no_disabled_needs_conjunction")) end end diff --git a/config/locales/en.yml b/config/locales/en.yml index 0e93c6342..98e1bc9de 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -347,7 +347,8 @@ en: 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" + 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" + dont_know_disabled_needs_conjunction: "Don’t know 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 589301439..a6d5bbf94 100644 --- a/spec/services/bulk_upload/lettings/row_parser_spec.rb +++ b/spec/services/bulk_upload/lettings/row_parser_spec.rb @@ -366,6 +366,16 @@ RSpec.describe BulkUpload::Lettings::RowParser do end end + describe "#field_60" do + context "when 1 and another disability field selected" do + let(:attributes) { { bulk_upload:, field_60: "1", field_58: "1" } } + + it "is not permitted" do + expect(parser.errors[:field_60]).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 } }