Browse Source

Validate no housing needs answers for 2023

pull/1611/head
Kat 3 years ago
parent
commit
fe3e6e8c83
  1. 11
      app/services/bulk_upload/lettings/year2023/row_parser.rb
  2. 14
      spec/services/bulk_upload/lettings/year2023/row_parser_spec.rb

11
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"))

14
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 } }

Loading…
Cancel
Save