Browse Source

CLDC-3224: Parse noint correctly in bulk upload row parsers

pull/2251/head
Rachael Booth 2 years ago
parent
commit
f9e23b1e8e
  1. 2
      app/services/bulk_upload/sales/year2023/row_parser.rb
  2. 2
      app/services/bulk_upload/sales/year2024/row_parser.rb
  3. 18
      spec/services/bulk_upload/sales/year2023/row_parser_spec.rb
  4. 18
      spec/services/bulk_upload/sales/year2024/row_parser_spec.rb

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

@ -791,7 +791,7 @@ private
attributes["purchid"] = purchaser_code attributes["purchid"] = purchaser_code
attributes["saledate"] = saledate attributes["saledate"] = saledate
attributes["noint"] = 2 if field_28 == 1 attributes["noint"] = field_28
attributes["age1_known"] = age1_known? attributes["age1_known"] = age1_known?
attributes["age1"] = field_30 if attributes["age1_known"]&.zero? && field_30&.match(/\A\d{1,3}\z|\AR\z/) attributes["age1"] = field_30 if attributes["age1_known"]&.zero? && field_30&.match(/\A\d{1,3}\z|\AR\z/)

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

@ -785,7 +785,7 @@ private
attributes["purchid"] = purchaser_code attributes["purchid"] = purchaser_code
attributes["saledate"] = saledate attributes["saledate"] = saledate
attributes["noint"] = 2 if field_17 == 1 attributes["noint"] = field_17
attributes["age1_known"] = age1_known? attributes["age1_known"] = age1_known?
attributes["age1"] = field_31 if attributes["age1_known"]&.zero? && field_31&.match(/\A\d{1,3}\z|\AR\z/) attributes["age1"] = field_31 if attributes["age1_known"]&.zero? && field_31&.match(/\A\d{1,3}\z|\AR\z/)

18
spec/services/bulk_upload/sales/year2023/row_parser_spec.rb

@ -1001,6 +1001,24 @@ RSpec.describe BulkUpload::Sales::Year2023::RowParser do
end end
describe "#log" do describe "#log" do
describe "#noint" do
context "when field is set to 1" do
let(:attributes) { valid_attributes.merge({ field_28: 1 }) }
it "is correctly set" do
expect(parser.log.noint).to be(1)
end
end
context "when field is set to 2" do
let(:attributes) { valid_attributes.merge({ field_28: 2 }) }
it "is correctly set" do
expect(parser.log.noint).to be(2)
end
end
end
describe "#uprn" do describe "#uprn" do
let(:attributes) { setup_section_params.merge({ field_19: "12" }) } let(:attributes) { setup_section_params.merge({ field_19: "12" }) }

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

@ -1023,6 +1023,24 @@ RSpec.describe BulkUpload::Sales::Year2024::RowParser do
end end
describe "#log" do describe "#log" do
describe "#noint" do
context "when field is set to 1" do
let(:attributes) { valid_attributes.merge({ field_17: 1 }) }
it "is correctly set" do
expect(parser.log.noint).to be(1)
end
end
context "when field is set to 2" do
let(:attributes) { valid_attributes.merge({ field_17: 2 }) }
it "is correctly set" do
expect(parser.log.noint).to be(2)
end
end
end
describe "#uprn" do describe "#uprn" do
let(:attributes) { setup_section_params.merge({ field_22: "12" }) } let(:attributes) { setup_section_params.merge({ field_22: "12" }) }

Loading…
Cancel
Save