From 03e5b38c960de0cf19020f182b24d28080279383 Mon Sep 17 00:00:00 2001 From: Phil Lee Date: Tue, 14 Feb 2023 11:19:50 +0000 Subject: [PATCH] add bulk upload validation - no and don't know disabled access needs cannot be selected together --- app/services/bulk_upload/lettings/row_parser.rb | 8 ++++++++ config/locales/en.yml | 5 +++-- spec/services/bulk_upload/lettings/row_parser_spec.rb | 11 +++++++++++ 3 files changed, 22 insertions(+), 2 deletions(-) diff --git a/app/services/bulk_upload/lettings/row_parser.rb b/app/services/bulk_upload/lettings/row_parser.rb index ff93e3b8b..bf1f62eba 100644 --- a/app/services/bulk_upload/lettings/row_parser.rb +++ b/app/services/bulk_upload/lettings/row_parser.rb @@ -153,6 +153,7 @@ class BulkUpload::Lettings::RowParser validate :validate_only_one_housing_needs_type validate :validate_no_disabled_needs_conjunction validate :validate_dont_know_disabled_needs_conjunction + validate :validate_no_and_dont_know_disabled_needs_conjunction def valid? errors.clear @@ -181,6 +182,13 @@ class BulkUpload::Lettings::RowParser private + def validate_no_and_dont_know_disabled_needs_conjunction + if field_59 == 1 && field_60 == 1 + errors.add(:field_59, I18n.t("validations.household.housingneeds.no_and_dont_know_disabled_needs_conjunction")) + errors.add(:field_60, I18n.t("validations.household.housingneeds.no_and_dont_know_disabled_needs_conjunction")) + end + end + 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")) diff --git a/config/locales/en.yml b/config/locales/en.yml index 98e1bc9de..1ac1f6560 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -347,8 +347,9 @@ 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: - 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" + no_disabled_needs_conjunction: "No disabled access 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 access 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_and_dont_know_disabled_needs_conjunction: "No disabled access needs and don’t know disabled access needs cannot be selected together" 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 a6d5bbf94..1bebd6444 100644 --- a/spec/services/bulk_upload/lettings/row_parser_spec.rb +++ b/spec/services/bulk_upload/lettings/row_parser_spec.rb @@ -376,6 +376,17 @@ RSpec.describe BulkUpload::Lettings::RowParser do end end + describe "#field_59, #field_60" do + context "when both 1" do + let(:attributes) { { bulk_upload:, field_59: "1", field_60: "1" } } + + it "is not permitted" do + expect(parser.errors[:field_59]).to be_present + 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 } }