From eb7f301974e30bb646ddd3a480c7dc621ffebc42 Mon Sep 17 00:00:00 2001 From: kosiakkatrina <54268893+kosiakkatrina@users.noreply.github.com> Date: Tue, 5 Dec 2023 13:05:31 +0000 Subject: [PATCH] CLDC-2071 Add intermediate rent error to BU (#2053) * Add intermediate rent error * Make sure field 12 as an error --- .../bulk_upload/lettings/year2023/row_parser.rb | 8 ++++++++ .../lettings/year2023/row_parser_spec.rb | 17 +++++++++++++++++ 2 files changed, 25 insertions(+) diff --git a/app/services/bulk_upload/lettings/year2023/row_parser.rb b/app/services/bulk_upload/lettings/year2023/row_parser.rb index 511f4336b..585ec7c93 100644 --- a/app/services/bulk_upload/lettings/year2023/row_parser.rb +++ b/app/services/bulk_upload/lettings/year2023/row_parser.rb @@ -329,6 +329,14 @@ class BulkUpload::Lettings::Year2023::RowParser }, on: :after_log + validates :field_11, + presence: { + if: proc { renttype == :intermediate }, + message: I18n.t("validations.not_answered", question: "intermediate rent type"), + category: :setup, + }, + on: :after_log + validates :field_15, presence: { if: proc { supported_housing? && log_uses_old_scheme_id? }, 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 dc7dbeaea..86e45ca2d 100644 --- a/spec/services/bulk_upload/lettings/year2023/row_parser_spec.rb +++ b/spec/services/bulk_upload/lettings/year2023/row_parser_spec.rb @@ -809,6 +809,23 @@ RSpec.describe BulkUpload::Lettings::Year2023::RowParser do end end + context "when intermediate rent and field_11 (Which type of Intermediate Rent) is not given" do + let(:attributes) { { bulk_upload:, field_5: "9", field_11: nil } } + + it "adds error on field_11" do + expect(parser.errors[:field_5]).to be_present + expect(parser.errors[:field_11]).to eq(["You must answer intermediate rent type"]) + end + end + + context "when intermediate rent other and field_12 is not given" do + let(:attributes) { { bulk_upload:, field_5: "9", field_11: "3", field_12: nil } } + + it "adds error on field_12" do + expect(parser.errors[:field_12]).to eq(["You must answer product name"]) + end + end + context "when bulk upload is for general needs" do context "when general needs option selected" do let(:attributes) { { bulk_upload:, field_5: "1", field_4: "1" } }