Browse Source

CLDC-3339 Improve select correct address bulk upload error (#2331)

* feat: add unable to find address errors when some options are returned if they are low confidence

* feat: update copy

* feat: add tests
pull/2337/head^2
natdeanlewissoftwire 9 months ago committed by GitHub
parent
commit
9881fb990a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 2
      app/services/bulk_upload/lettings/year2024/row_parser.rb
  2. 2
      app/services/bulk_upload/sales/year2024/row_parser.rb
  3. 2
      config/locales/en.yml
  4. 17
      spec/services/bulk_upload/lettings/year2024/row_parser_spec.rb
  5. 17
      spec/services/bulk_upload/sales/year2024/row_parser_spec.rb

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

@ -574,7 +574,7 @@ private
end
def validate_address_option_found
if !log.address_options_present? && field_16.blank? && (field_17.present? || field_19.present?)
if log.uprn_selection.nil? && field_16.blank? && (field_17.present? || field_19.present?)
%i[field_17 field_18 field_19 field_20 field_21 field_22].each do |field|
errors.add(field, I18n.t("validations.no_address_found"))
end

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

@ -602,7 +602,7 @@ private
end
def validate_address_option_found
if !log.address_options_present? && field_22.blank? && (field_23.present? || field_25.present?)
if log.uprn_selection.nil? && field_22.blank? && (field_23.present? || field_25.present?)
%i[field_23 field_24 field_25 field_26 field_27 field_28].each do |field|
errors.add(field, I18n.t("validations.no_address_found"))
end

2
config/locales/en.yml

@ -213,7 +213,7 @@ en:
not_answered: "You must answer %{question}"
invalid_option: "Enter a valid value for %{question}"
invalid_number: "Enter a number for %{question}"
no_address_found: "We could not find this address. Edit the address data or fix this error on the CORE site."
no_address_found: "We could not find this address. Check the address data in your CSV file is correct and complete, or select the correct address using the CORE site."
other_field_missing: "If %{main_field_label} is other then %{other_field_label} must be provided"
other_field_not_required: "%{other_field_label} must not be provided if %{main_field_label} was not other"

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

@ -1521,6 +1521,23 @@ RSpec.describe BulkUpload::Lettings::Year2024::RowParser do
end
end
describe "address fields" do
context "when no address can be found" do
before do
stub_request(:get, /api\.os\.uk\/search\/places\/v1\/find/)
.to_return(status: 200, body: nil, headers: {})
end
let(:attributes) { setup_section_params.merge({ field_16: nil, field_17: "address line 1", field_19: "town or city" }) }
it "adds an appropriate error" do
%i[field_17 field_18 field_19 field_20 field_21 field_22].each do |field|
expect(parser.errors[field]).to eql(["We could not find this address. Check the address data in your CSV file is correct and complete, or select the correct address using the CORE site."])
end
end
end
end
describe "#field_25" do # unitletas
context "when no longer a valid option from previous year" do
let(:attributes) { setup_section_params.merge({ field_25: "4" }) }

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

@ -886,6 +886,23 @@ RSpec.describe BulkUpload::Sales::Year2024::RowParser do
end
end
describe "address fields" do
context "when no address can be found" do
before do
stub_request(:get, /api\.os\.uk\/search\/places\/v1\/find/)
.to_return(status: 200, body: nil, headers: {})
end
let(:attributes) { setup_section_params.merge({ field_22: nil, field_23: "address line 1", field_25: "town or city" }) }
it "adds an appropriate error" do
%i[field_23 field_24 field_25 field_26 field_27 field_28].each do |field|
expect(parser.errors[field]).to eql(["We could not find this address. Check the address data in your CSV file is correct and complete, or select the correct address using the CORE site."])
end
end
end
end
describe "#field_18" do # data protection
let(:attributes) { setup_section_params.merge({ field_18: nil }) }

Loading…
Cancel
Save