Browse Source

add bulk upload validation

- dont know disabled needs cannot be selected in conjunction with a disabled need
pull/1299/head
Phil Lee 3 years ago
parent
commit
8ffd798cf6
  1. 9
      app/services/bulk_upload/lettings/row_parser.rb
  2. 3
      config/locales/en.yml
  3. 10
      spec/services/bulk_upload/lettings/row_parser_spec.rb

9
app/services/bulk_upload/lettings/row_parser.rb

@ -152,6 +152,7 @@ class BulkUpload::Lettings::RowParser
validate :validate_lettings_type_matches_bulk_upload
validate :validate_only_one_housing_needs_type
validate :validate_no_disabled_needs_conjunction
validate :validate_dont_know_disabled_needs_conjunction
def valid?
errors.clear
@ -180,9 +181,15 @@ class BulkUpload::Lettings::RowParser
private
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"))
end
end
def validate_no_disabled_needs_conjunction
if field_59 == 1 && [field_55, field_56, field_57, field_58].compact.count.positive?
errors.add(:field_59, I18n.t("validations.household.housingneeds.validate_no_disabled_needs_conjunction"))
errors.add(:field_59, I18n.t("validations.household.housingneeds.no_disabled_needs_conjunction"))
end
end

3
config/locales/en.yml

@ -347,7 +347,8 @@ 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:
validate_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"
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"
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"

10
spec/services/bulk_upload/lettings/row_parser_spec.rb

@ -366,6 +366,16 @@ RSpec.describe BulkUpload::Lettings::RowParser do
end
end
describe "#field_60" do
context "when 1 and another disability field selected" do
let(:attributes) { { bulk_upload:, field_60: "1", field_58: "1" } }
it "is not permitted" do
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 } }

Loading…
Cancel
Save