Browse Source

bulk upload only permits one housing needs type

pull/1299/head
Phil Lee 3 years ago
parent
commit
7e9655f860
  1. 9
      app/services/bulk_upload/lettings/row_parser.rb
  2. 2
      config/locales/en.yml
  3. 12
      spec/services/bulk_upload/lettings/row_parser_spec.rb

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

@ -150,6 +150,7 @@ class BulkUpload::Lettings::RowParser
validate :validate_cannot_be_la_referral_if_general_needs
validate :validate_leaving_reason_for_renewal
validate :validate_lettings_type_matches_bulk_upload
validate :validate_only_one_housing_needs_type
def valid?
errors.clear
@ -178,6 +179,14 @@ class BulkUpload::Lettings::RowParser
private
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"))
errors.add(:field_56, I18n.t("validations.household.housingneeds_type.only_one_option_permitted"))
errors.add(:field_57, I18n.t("validations.household.housingneeds_type.only_one_option_permitted"))
end
end
def validate_lettings_type_matches_bulk_upload
if [1, 3, 5, 7, 9, 11].include?(field_1) && !bulk_upload.general_needs?
errors.add(:field_1, I18n.t("validations.setup.lettype.supported_housing_mismatch"))

2
config/locales/en.yml

@ -344,6 +344,8 @@ en:
must_be_child: "Answer must be ‘child’ if the person is aged 16-19 and a student"
housingneeds_a:
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"
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"

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

@ -344,6 +344,18 @@ RSpec.describe BulkUpload::Lettings::RowParser do
end
end
describe "#field_55, #field_56, #field_57" do
context "when more than one item selected" do
let(:attributes) { { bulk_upload:, field_55: "1", field_56: "1" } }
it "is not permitted" do
expect(parser.errors[:field_55]).to be_present
expect(parser.errors[:field_56]).to be_present
expect(parser.errors[:field_57]).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