From 6bdf9f394505c073ff274a4481053fac4a368c4a Mon Sep 17 00:00:00 2001 From: kosiakkatrina <54268893+kosiakkatrina@users.noreply.github.com> Date: Tue, 2 Jan 2024 08:31:49 +0000 Subject: [PATCH] CLDC-2956 Update allocation system error messages (#2099) * Update error messages * validate lettings allocation * Switch question field numbers --- .../bulk_upload/lettings/year2023/row_parser.rb | 15 ++++++++++++--- .../lettings/year2023/row_parser_spec.rb | 12 ++++++++++++ 2 files changed, 24 insertions(+), 3 deletions(-) diff --git a/app/services/bulk_upload/lettings/year2023/row_parser.rb b/app/services/bulk_upload/lettings/year2023/row_parser.rb index 25b00302c..5c726b8fa 100644 --- a/app/services/bulk_upload/lettings/year2023/row_parser.rb +++ b/app/services/bulk_upload/lettings/year2023/row_parser.rb @@ -119,9 +119,9 @@ class BulkUpload::Lettings::Year2023::RowParser field_113: "Reasonable preference reason They needed to move on medical and welfare reasons (including disability)", field_114: "Reasonable preference reason They needed to move to avoid hardship to themselves or others", field_115: "Reasonable preference reason Don't know", - field_116: "How was this letting allocated?", - field_117: "How was this letting allocated?", - field_118: "How was this letting allocated?", + field_116: "Was the letting made under the Choice-Based Lettings (CBL)?", + field_117: "Was the letting made under the Common Allocation Policy (CAP)?", + field_118: "Was the letting made under the Common Housing Register (CHR)?", field_119: "What was the source of referral for this letting?", field_120: "Do you know the household's combined total income after tax?", field_121: "How often does the household receive income?", @@ -384,6 +384,7 @@ class BulkUpload::Lettings::Year2023::RowParser validate :validate_no_housing_needs_questions_answered, on: :after_log validate :validate_reasonable_preference_homeless, on: :after_log validate :validate_condition_effects, on: :after_log + validate :validate_lettings_allocation, 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 @@ -669,6 +670,14 @@ private end end + def validate_lettings_allocation + if cbl.blank? && cap.blank? && chr.blank? + errors.add(:field_116, I18n.t("validations.not_answered", question: "was the letting made under the Choice-Based Lettings (CBL)?")) + errors.add(:field_117, I18n.t("validations.not_answered", question: "was the letting made under the Common Allocation Policy (CAP)?")) + errors.add(:field_118, I18n.t("validations.not_answered", question: "was the letting made under the Common Housing Register (CHR)?")) + end + end + def household_no_illness? field_89 != 1 end 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 af713d29b..90bdbed71 100644 --- a/spec/services/bulk_upload/lettings/year2023/row_parser_spec.rb +++ b/spec/services/bulk_upload/lettings/year2023/row_parser_spec.rb @@ -1217,6 +1217,18 @@ RSpec.describe BulkUpload::Lettings::Year2023::RowParser do end end + describe "#field_116, 117, 118" do + context "when none of field_116, 117, 118 are given" do + let(:attributes) { { bulk_upload:, field_116: "", field_117: "", field_118: "", field_89: "1" } } + + it "sets correct errors" do + expect(parser.errors[:field_116]).to include("You must answer was the letting made under the Choice-Based Lettings (CBL)?") + expect(parser.errors[:field_117]).to include("You must answer was the letting made under the Common Allocation Policy (CAP)?") + expect(parser.errors[:field_118]).to include("You must answer was the letting made under the Common Housing Register (CHR)?") + end + end + end + describe "#field_105, field_110 - 15" do context "when there is a reasonable preference but none is given" do let(:attributes) { { bulk_upload:, field_110: "1", field_111: nil, field_112: nil, field_113: nil, field_114: nil, field_115: nil } }