Browse Source

Update error messaging for single and multiple returns

Fix-copy-multiple-matches-for-this-address
Manny Dinssa 1 week ago
parent
commit
e4e1a04be9
  1. 4
      app/services/bulk_upload/lettings/year2024/row_parser.rb
  2. 4
      app/services/bulk_upload/sales/year2024/row_parser.rb
  3. 6
      config/locales/validations/lettings/2024/bulk_upload.en.yml
  4. 6
      config/locales/validations/sales/2024/bulk_upload.en.yml
  5. 28
      spec/services/bulk_upload/lettings/year2024/row_parser_spec.rb
  6. 4
      spec/services/bulk_upload/sales/year2024/row_parser_spec.rb

4
app/services/bulk_upload/lettings/year2024/row_parser.rb

@ -617,7 +617,9 @@ private
def validate_address_option_found def validate_address_option_found
if log.uprn.nil? && field_16.blank? && key_address_fields_provided? if log.uprn.nil? && field_16.blank? && key_address_fields_provided?
error_message = if log.address_options_present? && log.address_options.size > 1 error_message = if log.address_options_present? && log.address_options.size > 1
I18n.t("#{ERROR_BASE_KEY}.address.not_determined") I18n.t("#{ERROR_BASE_KEY}.address.not_determined.multiple")
elsif log.address_options_present?
I18n.t("#{ERROR_BASE_KEY}.address.not_determined.one")
else else
I18n.t("#{ERROR_BASE_KEY}.address.not_found") I18n.t("#{ERROR_BASE_KEY}.address.not_found")
end end

4
app/services/bulk_upload/sales/year2024/row_parser.rb

@ -615,7 +615,9 @@ private
def validate_address_option_found def validate_address_option_found
if log.uprn.nil? && field_22.blank? && key_address_fields_provided? if log.uprn.nil? && field_22.blank? && key_address_fields_provided?
error_message = if log.address_options_present? && log.address_options.size > 1 error_message = if log.address_options_present? && log.address_options.size > 1
I18n.t("#{ERROR_BASE_KEY}.address.not_determined") I18n.t("#{ERROR_BASE_KEY}.address.not_determined.multiple")
elsif log.address_options_present?
I18n.t("#{ERROR_BASE_KEY}.address.not_determined.one")
else else
I18n.t("#{ERROR_BASE_KEY}.address.not_found") I18n.t("#{ERROR_BASE_KEY}.address.not_found")
end end

6
config/locales/validations/lettings/2024/bulk_upload.en.yml

@ -49,8 +49,10 @@ en:
age: age:
invalid: "Age of person %{person_num} must be a number or the letter R" invalid: "Age of person %{person_num} must be a number or the letter R"
address: address:
not_found: "We could not find this address. Check the address data in your CSV file is correct and complete, or find the correct address using the CORE site." not_found: "We could not find this address. Check the address data in your CSV file is correct and complete, or find the correct address in the service."
not_determined: "There are multiple matches for this address. Check the address data in your CSV file is correct and complete, or select the correct address using the CORE site." not_determined:
one: "There is a possible match for this address which doesn't look right. Check the address data in your CSV file is correct and complete, or confirm the address in the service."
multiple: "There are multiple matches for this address. Check the address data in your CSV file is correct and complete, or select the correct address in the service."
not_answered: "Enter either the UPRN or the full address." not_answered: "Enter either the UPRN or the full address."
nationality: nationality:
invalid: "Select a valid nationality." invalid: "Select a valid nationality."

6
config/locales/validations/sales/2024/bulk_upload.en.yml

@ -39,8 +39,10 @@ en:
age2: age2:
buyer_cannot_be_over_16_and_child: "Buyer 2's age cannot be 16 or over if their working situation is child under 16." buyer_cannot_be_over_16_and_child: "Buyer 2's age cannot be 16 or over if their working situation is child under 16."
address: address:
not_found: "We could not find this address. Check the address data in your CSV file is correct and complete, or find the correct address using the CORE site." not_found: "We could not find this address. Check the address data in your CSV file is correct and complete, or find the correct address in the service."
not_determined: "There are multiple matches for this address. Check the address data in your CSV file is correct and complete, or select the correct address using the CORE site." not_determined:
one: "There is a possible match for this address which doesn't look right. Check the address data in your CSV file is correct and complete, or confirm the address in the service."
multiple: "There are multiple matches for this address. Check the address data in your CSV file is correct and complete, or select the correct address in the service."
not_answered: "Enter either the UPRN or the full address." not_answered: "Enter either the UPRN or the full address."
nationality: nationality:
invalid: "Select a valid nationality." invalid: "Select a valid nationality."

28
spec/services/bulk_upload/lettings/year2024/row_parser_spec.rb

@ -1710,7 +1710,7 @@ RSpec.describe BulkUpload::Lettings::Year2024::RowParser do
end end
end end
context "when no address has a high enough match rating" do context "when a single address with not a high enough match rating is returned" do
before do before do
stub_request(:get, /api\.os\.uk\/search\/places\/v1\/find/) stub_request(:get, /api\.os\.uk\/search\/places\/v1\/find/)
.to_return(status: 200, body: { results: [{ DPA: { MATCH: 0.6, BUILDING_NAME: "", POST_TOWN: "", POSTCODE: "AA1 1AA", UPRN: "1" } }] }.to_json, headers: {}) .to_return(status: 200, body: { results: [{ DPA: { MATCH: 0.6, BUILDING_NAME: "", POST_TOWN: "", POSTCODE: "AA1 1AA", UPRN: "1" } }] }.to_json, headers: {})
@ -1720,7 +1720,31 @@ RSpec.describe BulkUpload::Lettings::Year2024::RowParser do
parser.valid? parser.valid?
expect(parser.errors[:field_16]).to be_empty expect(parser.errors[:field_16]).to be_empty
%i[field_17 field_18 field_19 field_20 field_21 field_22].each do |field| %i[field_17 field_18 field_19 field_20 field_21 field_22].each do |field|
expect(parser.errors[field]).to eql([I18n.t("validations.lettings.2024.bulk_upload.address.not_determined")]) expect(parser.errors[field]).to eql([I18n.t("validations.lettings.2024.bulk_upload.address.not_determined.one")])
end
end
end
context "when no addresses have a high enough match rating" do
before do
stub_request(:get, /api\.os\.uk\/search\/places\/v1\/find/)
.to_return(
status: 200,
body: {
results: [
{ DPA: { MATCH: 0.6, BUILDING_NAME: "", POST_TOWN: "", POSTCODE: "AA1 1AA", UPRN: "1" } },
{ DPA: { MATCH: 0.8, BUILDING_NAME: "", POST_TOWN: "", POSTCODE: "BB2 2BB", UPRN: "2" } },
]
}.to_json,
headers: {},
)
end
it "adds address not found errors to address fields only" do
parser.valid?
expect(parser.errors[:field_16]).to be_empty
%i[field_17 field_18 field_19 field_20 field_21 field_22].each do |field|
expect(parser.errors[field]).to eql([I18n.t("validations.lettings.2024.bulk_upload.address.not_determined.multiple")])
end end
end end
end end

4
spec/services/bulk_upload/sales/year2024/row_parser_spec.rb

@ -1104,7 +1104,7 @@ RSpec.describe BulkUpload::Sales::Year2024::RowParser do
parser.valid? parser.valid?
expect(parser.errors[:field_22]).to be_empty expect(parser.errors[:field_22]).to be_empty
%i[field_23 field_24 field_25 field_26 field_27 field_28].each do |field| %i[field_23 field_24 field_25 field_26 field_27 field_28].each do |field|
expect(parser.errors[field]).to eql([I18n.t("validations.sales.2024.bulk_upload.address.not_found")]) expect(parser.errors[field]).to eql([I18n.t("validations.sales.2024.bulk_upload.address.not_determined.one")])
end end
end end
end end
@ -1128,7 +1128,7 @@ RSpec.describe BulkUpload::Sales::Year2024::RowParser do
parser.valid? parser.valid?
expect(parser.errors[:field_22]).to be_empty expect(parser.errors[:field_22]).to be_empty
%i[field_23 field_24 field_25 field_26 field_27 field_28].each do |field| %i[field_23 field_24 field_25 field_26 field_27 field_28].each do |field|
expect(parser.errors[field]).to eql([I18n.t("validations.sales.2024.bulk_upload.address.not_determined")]) expect(parser.errors[field]).to eql([I18n.t("validations.sales.2024.bulk_upload.address.not_determined.multiple")])
end end
end end
end end

Loading…
Cancel
Save