Browse Source

Merge branch 'main' into CLDC-2257-refactor-filters-3

pull/1675/head
natdeanlewissoftwire 3 years ago
parent
commit
9fdd80e9f2
  1. 1
      app/services/bulk_upload/lettings/year2022/csv_parser.rb
  2. 1
      app/services/bulk_upload/lettings/year2023/csv_parser.rb
  3. 1
      app/services/bulk_upload/sales/year2022/csv_parser.rb
  4. 1
      app/services/bulk_upload/sales/year2023/csv_parser.rb
  5. 18
      spec/services/bulk_upload/lettings/year2022/csv_parser_spec.rb
  6. 18
      spec/services/bulk_upload/lettings/year2023/csv_parser_spec.rb
  7. 22
      spec/services/bulk_upload/sales/year2022/csv_parser_spec.rb
  8. 18
      spec/services/bulk_upload/sales/year2023/csv_parser_spec.rb

1
app/services/bulk_upload/lettings/year2022/csv_parser.rb

@ -93,6 +93,7 @@ private
@normalised_string = File.read(path, encoding: "bom|utf-8")
@normalised_string.gsub!("\r\n", "\n")
@normalised_string.scrub!("")
@normalised_string.tr!("\r", "\n")
@normalised_string
end

1
app/services/bulk_upload/lettings/year2023/csv_parser.rb

@ -98,6 +98,7 @@ private
@normalised_string = File.read(path, encoding: "bom|utf-8")
@normalised_string.gsub!("\r\n", "\n")
@normalised_string.scrub!("")
@normalised_string.tr!("\r", "\n")
@normalised_string
end

1
app/services/bulk_upload/sales/year2022/csv_parser.rb

@ -67,6 +67,7 @@ private
@normalised_string = File.read(path, encoding: "bom|utf-8")
@normalised_string.gsub!("\r\n", "\n")
@normalised_string.scrub!("")
@normalised_string.tr!("\r", "\n")
@normalised_string
end

1
app/services/bulk_upload/sales/year2023/csv_parser.rb

@ -93,6 +93,7 @@ private
@normalised_string = File.read(path, encoding: "bom|utf-8")
@normalised_string.gsub!("\r\n", "\n")
@normalised_string.scrub!("")
@normalised_string.tr!("\r", "\n")
@normalised_string
end

18
spec/services/bulk_upload/lettings/year2022/csv_parser_spec.rb

@ -169,4 +169,22 @@ RSpec.describe BulkUpload::Lettings::Year2022::CsvParser do
end
end
end
context "when parsing csv with carriage returns" do
before do
file.write("Question\r\n")
file.write("Additional info\r")
file.write("Values\r\n")
file.write("Can be empty?\r")
file.write("Type of letting the question applies to\r\n")
file.write("Duplicate check field?\r")
file.write(BulkUpload::LettingsLogToCsv.new(log:).default_2022_field_numbers_row)
file.write(BulkUpload::LettingsLogToCsv.new(log:).to_2022_csv_row)
file.rewind
end
it "parses csv correctly" do
expect(service.row_parsers[0].field_12.to_i).to eq(35)
end
end
end

18
spec/services/bulk_upload/lettings/year2023/csv_parser_spec.rb

@ -150,6 +150,24 @@ RSpec.describe BulkUpload::Lettings::Year2023::CsvParser do
end
end
context "when parsing csv with carriage returns" do
before do
file.write("Question\r\n")
file.write("Additional info\r")
file.write("Values\r\n")
file.write("Can be empty?\r")
file.write("Type of letting the question applies to\r\n")
file.write("Duplicate check field?\r")
file.write(BulkUpload::LettingsLogToCsv.new(log:).default_2023_field_numbers_row)
file.write(BulkUpload::LettingsLogToCsv.new(log:).to_2023_csv_row)
file.rewind
end
it "parses csv correctly" do
expect(service.row_parsers[0].field_13).to eql(log.tenancycode)
end
end
describe "#column_for_field", aggregate_failures: true do
context "when with headers using default ordering" do
before do

22
spec/services/bulk_upload/sales/year2022/csv_parser_spec.rb

@ -94,4 +94,26 @@ RSpec.describe BulkUpload::Sales::Year2022::CsvParser do
end
end
end
context "when parsing csv with carriage returns" do
let(:file) { Tempfile.new }
let(:path) { file.path }
let(:log) { build(:sales_log, :completed) }
before do
file.write("Question\r\n")
file.write("Additional info\r")
file.write("Values\r\n")
file.write("Can be empty?\r")
file.write("Type of letting the question applies to\r\n")
file.write("Duplicate check field?\r")
file.write(BulkUpload::SalesLogToCsv.new(log:).to_2022_csv_row)
file.rewind
end
it "parses csv correctly" do
expect(service.column_for_field("field_1")).to eql("A")
expect(service.column_for_field("field_125")).to eql("DU")
end
end
end

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

@ -145,4 +145,22 @@ RSpec.describe BulkUpload::Sales::Year2023::CsvParser do
end
end
end
context "when parsing csv with carriage returns" do
before do
file.write("Question\r\n")
file.write("Additional info\r")
file.write("Values\r\n")
file.write("Can be empty?\r")
file.write("Type of letting the question applies to\r\n")
file.write("Duplicate check field?\r")
file.write(BulkUpload::SalesLogToCsv.new(log:).default_2023_field_numbers_row)
file.write(BulkUpload::SalesLogToCsv.new(log:).to_2023_csv_row)
file.rewind
end
it "parses csv correctly" do
expect(service.row_parsers[0].field_19).to eql(log.uprn)
end
end
end

Loading…
Cancel
Save