Browse Source

feat: add tests

pull/2331/head
natdeanlewissoftwire 2 years ago
parent
commit
3b0a6064f2
  1. 17
      spec/services/bulk_upload/lettings/year2024/row_parser_spec.rb
  2. 17
      spec/services/bulk_upload/sales/year2024/row_parser_spec.rb

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

@ -1521,6 +1521,23 @@ RSpec.describe BulkUpload::Lettings::Year2024::RowParser do
end end
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 describe "#field_25" do # unitletas
context "when no longer a valid option from previous year" do context "when no longer a valid option from previous year" do
let(:attributes) { setup_section_params.merge({ field_25: "4" }) } 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
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 describe "#field_18" do # data protection
let(:attributes) { setup_section_params.merge({ field_18: nil }) } let(:attributes) { setup_section_params.merge({ field_18: nil }) }

Loading…
Cancel
Save