diff --git a/app/services/bulk_upload/lettings/year2022/row_parser.rb b/app/services/bulk_upload/lettings/year2022/row_parser.rb index 62cf9e872..953487cd7 100644 --- a/app/services/bulk_upload/lettings/year2022/row_parser.rb +++ b/app/services/bulk_upload/lettings/year2022/row_parser.rb @@ -340,6 +340,7 @@ class BulkUpload::Lettings::Year2022::RowParser validate :validate_no_disabled_needs_conjunction, on: :after_log validate :validate_dont_know_disabled_needs_conjunction, on: :after_log validate :validate_no_and_dont_know_disabled_needs_conjunction, on: :after_log + validate :validate_no_housing_needs_questions_answered, on: :after_log validate :validate_if_log_already_exists, on: :after_log, if: -> { FeatureToggle.bulk_upload_duplicate_log_check_enabled? } validate :validate_owning_org_data_given, on: :after_log @@ -648,6 +649,16 @@ private end end + def validate_no_housing_needs_questions_answered + if [field_55, field_56, field_57, field_58, field_59, field_60].all?(&:blank?) + errors.add(:field_59, I18n.t("validations.not_answered", question: "anybody with disabled access needs")) + errors.add(:field_58, I18n.t("validations.not_answered", question: "other access needs")) + %i[field_55 field_56 field_57].each do |field| + errors.add(field, I18n.t("validations.not_answered", question: "disabled access needs type")) + end + end + end + def validate_lettings_type_matches_bulk_upload if [1, 3, 5, 7, 9, 11].include?(field_1) && !bulk_upload.general_needs? errors.add(:field_1, I18n.t("validations.setup.lettype.supported_housing_mismatch")) diff --git a/app/services/bulk_upload/lettings/year2023/row_parser.rb b/app/services/bulk_upload/lettings/year2023/row_parser.rb index 9dc5b60de..85abd180d 100644 --- a/app/services/bulk_upload/lettings/year2023/row_parser.rb +++ b/app/services/bulk_upload/lettings/year2023/row_parser.rb @@ -356,6 +356,7 @@ class BulkUpload::Lettings::Year2023::RowParser validate :validate_no_disabled_needs_conjunction, on: :after_log validate :validate_dont_know_disabled_needs_conjunction, on: :after_log validate :validate_no_and_dont_know_disabled_needs_conjunction, on: :after_log + validate :validate_no_housing_needs_questions_answered, on: :after_log validate :validate_if_log_already_exists, on: :after_log, if: -> { FeatureToggle.bulk_upload_duplicate_log_check_enabled? } validate :validate_owning_org_data_given, on: :after_log @@ -584,6 +585,16 @@ private end end + def validate_no_housing_needs_questions_answered + if [field_83, field_84, field_85, field_86, field_87, field_88].all?(&:blank?) + errors.add(:field_87, I18n.t("validations.not_answered", question: "anybody with disabled access needs")) + errors.add(:field_86, I18n.t("validations.not_answered", question: "other access needs")) + %i[field_83 field_84 field_85].each do |field| + errors.add(field, I18n.t("validations.not_answered", question: "disabled access needs type")) + end + end + end + def validate_lettings_type_matches_bulk_upload if [1, 3, 5, 7, 9, 11].include?(field_5) && !general_needs? errors.add(:field_5, I18n.t("validations.setup.lettype.supported_housing_mismatch")) diff --git a/spec/services/bulk_upload/lettings/year2022/row_parser_spec.rb b/spec/services/bulk_upload/lettings/year2022/row_parser_spec.rb index 99adb049a..0587c0f51 100644 --- a/spec/services/bulk_upload/lettings/year2022/row_parser_spec.rb +++ b/spec/services/bulk_upload/lettings/year2022/row_parser_spec.rb @@ -959,6 +959,20 @@ RSpec.describe BulkUpload::Lettings::Year2022::RowParser do end end + describe "#field_55 - #field_60" do + context "when all blank" do + let(:attributes) { setup_section_params.merge({ field_55: nil, field_56: nil, field_57: nil, field_58: nil, field_59: nil, field_60: nil }) } + + it "adds errors to correct fields" do + expect(parser.errors[:field_55]).to be_present + expect(parser.errors[:field_56]).to be_present + expect(parser.errors[:field_57]).to be_present + expect(parser.errors[:field_58]).to be_present + expect(parser.errors[:field_59]).to be_present + end + end + end + describe "soft validations" do context "when soft validation is triggered" do let(:attributes) { setup_section_params.merge({ field_12: 22, field_35: 5 }) } diff --git a/spec/services/bulk_upload/lettings/year2023/row_parser_spec.rb b/spec/services/bulk_upload/lettings/year2023/row_parser_spec.rb index ef9935b44..d881b972b 100644 --- a/spec/services/bulk_upload/lettings/year2023/row_parser_spec.rb +++ b/spec/services/bulk_upload/lettings/year2023/row_parser_spec.rb @@ -675,6 +675,20 @@ RSpec.describe BulkUpload::Lettings::Year2023::RowParser do end end + describe "#field_83 - #field_88" do + context "when all blank" do + let(:attributes) { setup_section_params.merge({ field_83: nil, field_84: nil, field_85: nil, field_86: nil, field_87: nil, field_88: nil }) } + + it "adds errors to correct fields" do + expect(parser.errors[:field_83]).to be_present + expect(parser.errors[:field_84]).to be_present + expect(parser.errors[:field_85]).to be_present + expect(parser.errors[:field_86]).to be_present + expect(parser.errors[:field_87]).to be_present + end + end + end + describe "#field_119" do # referral context "when 3 ie PRP nominated by LA and owning org is LA" do let(:attributes) { { bulk_upload:, field_119: "3", field_1: owning_org.old_visible_id } }