Browse Source

add bulk upload validation

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

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

@ -151,6 +151,7 @@ class BulkUpload::Lettings::RowParser
validate :validate_leaving_reason_for_renewal
validate :validate_lettings_type_matches_bulk_upload
validate :validate_only_one_housing_needs_type
validate :validate_no_disabled_needs_conjunction
def valid?
errors.clear
@ -179,6 +180,12 @@ class BulkUpload::Lettings::RowParser
private
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"))
end
end
def validate_only_one_housing_needs_type
if [field_55, field_56, field_57].compact.count.positive?
errors.add(:field_55, I18n.t("validations.household.housingneeds_type.only_one_option_permitted"))

2
config/locales/en.yml

@ -346,6 +346,8 @@ en:
one_or_two_choices: "You can only select one option or ‘other disabled access needs’ plus ‘wheelchair-accessible housing’, ‘wheelchair access to essential rooms’ or ‘level access housing’"
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"
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

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