Browse Source

Update type missmatch error messages (#2105)

pull/2109/head
kosiakkatrina 12 months ago committed by GitHub
parent
commit
ba005a626b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 8
      app/services/bulk_upload/lettings/year2023/row_parser.rb
  2. 5
      config/locales/en.yml
  3. 8
      spec/services/bulk_upload/lettings/year2023/row_parser_spec.rb

8
app/services/bulk_upload/lettings/year2023/row_parser.rb

@ -684,11 +684,15 @@ private
def validate_lettings_type_matches_bulk_upload def validate_lettings_type_matches_bulk_upload
if [1, 3, 5, 7, 9, 11].include?(field_5) && !general_needs? if [1, 3, 5, 7, 9, 11].include?(field_5) && !general_needs?
errors.add(:field_5, I18n.t("validations.setup.lettype.supported_housing_mismatch")) block_log_creation!
errors.add(:field_4, I18n.t("validations.setup.needstype.lettype_not_supported_housing"), category: :setup)
errors.add(:field_5, I18n.t("validations.setup.lettype.needstype_supported_housing"), category: :setup)
end end
if [2, 4, 6, 8, 10, 12].include?(field_5) && !supported_housing? if [2, 4, 6, 8, 10, 12].include?(field_5) && !supported_housing?
errors.add(:field_5, I18n.t("validations.setup.lettype.general_needs_mismatch")) block_log_creation!
errors.add(:field_4, I18n.t("validations.setup.needstype.lettype_not_general_needs"), category: :setup)
errors.add(:field_5, I18n.t("validations.setup.lettype.needstype_general_needs"), category: :setup)
end end
end end

5
config/locales/en.yml

@ -307,6 +307,11 @@ en:
lettype: lettype:
general_needs_mismatch: Lettings type must be a general needs type because you selected general needs when uploading the file general_needs_mismatch: Lettings type must be a general needs type because you selected general needs when uploading the file
supported_housing_mismatch: Lettings type must be a supported housing type because you selected supported housing when uploading the file supported_housing_mismatch: Lettings type must be a supported housing type because you selected supported housing when uploading the file
needstype_general_needs: This needs type is general needs, but the letting type is supported housing. Change either the needs type or the letting type.
needstype_supported_housing: This needs type is supported housing, but the letting type is general needs. Change either the needs type or the letting type.
needstype:
lettype_not_general_needs: This letting type is supported housing, but the needs type is general needs. Change either the needs type or the letting type.
lettype_not_supported_housing: This letting type is general needs, but the needs type is supported housing. Change either the needs type or the letting type.
location: location:
incomplete: "This location is incomplete. Select another location or update this one" incomplete: "This location is incomplete. Select another location or update this one"

8
spec/services/bulk_upload/lettings/year2023/row_parser_spec.rb

@ -816,6 +816,7 @@ RSpec.describe BulkUpload::Lettings::Year2023::RowParser do
let(:attributes) { { bulk_upload:, field_5: "1", field_4: "1" } } let(:attributes) { { bulk_upload:, field_5: "1", field_4: "1" } }
it "is permitted" do it "is permitted" do
expect(parser.errors[:field_4]).to be_blank
expect(parser.errors[:field_5]).to be_blank expect(parser.errors[:field_5]).to be_blank
end end
end end
@ -824,7 +825,8 @@ RSpec.describe BulkUpload::Lettings::Year2023::RowParser do
let(:attributes) { { bulk_upload:, field_5: "2", field_4: "1" } } let(:attributes) { { bulk_upload:, field_5: "2", field_4: "1" } }
it "is not permitted" do it "is not permitted" do
expect(parser.errors[:field_5]).to include("Lettings type must be a general needs type because you selected general needs when uploading the file") expect(parser.errors[:field_4]).to include("This letting type is supported housing, but the needs type is general needs. Change either the needs type or the letting type.")
expect(parser.errors[:field_5]).to include("This needs type is general needs, but the letting type is supported housing. Change either the needs type or the letting type.")
end end
end end
end end
@ -836,7 +838,8 @@ RSpec.describe BulkUpload::Lettings::Year2023::RowParser do
let(:attributes) { { bulk_upload:, field_5: "1", field_4: "2" } } let(:attributes) { { bulk_upload:, field_5: "1", field_4: "2" } }
it "is not permitted" do it "is not permitted" do
expect(parser.errors[:field_5]).to include("Lettings type must be a supported housing type because you selected supported housing when uploading the file") expect(parser.errors[:field_4]).to include("This letting type is general needs, but the needs type is supported housing. Change either the needs type or the letting type.")
expect(parser.errors[:field_5]).to include("This needs type is supported housing, but the letting type is general needs. Change either the needs type or the letting type.")
end end
end end
@ -844,6 +847,7 @@ RSpec.describe BulkUpload::Lettings::Year2023::RowParser do
let(:attributes) { { bulk_upload:, field_5: "2", field_4: "2" } } let(:attributes) { { bulk_upload:, field_5: "2", field_4: "2" } }
it "is permitted" do it "is permitted" do
expect(parser.errors[:field_4]).to be_blank
expect(parser.errors[:field_5]).to be_blank expect(parser.errors[:field_5]).to be_blank
end end
end end

Loading…
Cancel
Save