|
|
|
@ -280,58 +280,5 @@ RSpec.describe BulkUpload::Lettings::Validator do
|
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
context "when a column has error rate above absolute threshold" do |
|
|
|
|
before do |
|
|
|
|
stub_const("BulkUpload::Lettings::Validator::COLUMN_ABSOLUTE_ERROR_THRESHOLD", 1) |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
context "when a column is over 60% error threshold" do |
|
|
|
|
let(:log_1) { build(:lettings_log, :completed, renttype: 1, created_by: user) } |
|
|
|
|
let(:log_2) { build(:lettings_log, renttype: 2, created_by: user, builtype: nil, startdate: Time.zone.local(2022, 5, 1)) } |
|
|
|
|
let(:log_3) { build(:lettings_log, renttype: 2, created_by: user, builtype: nil, startdate: Time.zone.local(2022, 5, 1)) } |
|
|
|
|
let(:log_4) { build(:lettings_log, renttype: 2, created_by: user, builtype: nil, startdate: Time.zone.local(2022, 5, 1)) } |
|
|
|
|
let(:log_5) { build(:lettings_log, renttype: 2, created_by: user, builtype: nil, startdate: Time.zone.local(2022, 5, 1)) } |
|
|
|
|
|
|
|
|
|
before do |
|
|
|
|
file.write(BulkUpload::LogToCsv.new(log: log_1, line_ending: "\r\n", col_offset: 0).to_2022_csv_row) |
|
|
|
|
file.write(BulkUpload::LogToCsv.new(log: log_2, line_ending: "\r\n", col_offset: 0).to_2022_csv_row) |
|
|
|
|
file.write(BulkUpload::LogToCsv.new(log: log_3, line_ending: "\r\n", col_offset: 0).to_2022_csv_row) |
|
|
|
|
file.write(BulkUpload::LogToCsv.new(log: log_4, line_ending: "\r\n", col_offset: 0).to_2022_csv_row) |
|
|
|
|
file.write(BulkUpload::LogToCsv.new(log: log_5, line_ending: "\r\n", col_offset: 0).to_2022_csv_row) |
|
|
|
|
file.close |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
it "returns false" do |
|
|
|
|
validator.call |
|
|
|
|
expect(validator).not_to be_create_logs |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
context "when a column is under 60% error threshold" do |
|
|
|
|
let(:log_1) { build(:lettings_log, :completed, renttype: 1, created_by: user) } |
|
|
|
|
let(:log_2) { build(:lettings_log, :completed, renttype: 1, created_by: user) } |
|
|
|
|
let(:log_3) { build(:lettings_log, renttype: 2, created_by: user, builtype: nil, startdate: Time.zone.local(2022, 5, 1)) } |
|
|
|
|
let(:log_4) { build(:lettings_log, renttype: 2, created_by: user, builtype: nil, startdate: Time.zone.local(2022, 5, 1)) } |
|
|
|
|
let(:log_5) { build(:lettings_log, renttype: 2, created_by: user, builtype: nil, startdate: Time.zone.local(2022, 5, 1)) } |
|
|
|
|
|
|
|
|
|
before do |
|
|
|
|
overrides = { age1: 50, age2: "R", age3: "R", age4: "4", age5: "R", age6: "R", age7: "R", age8: "R" } |
|
|
|
|
|
|
|
|
|
file.write(BulkUpload::LogToCsv.new(log: log_1, line_ending: "\r\n", col_offset: 0, overrides:).to_2022_csv_row) |
|
|
|
|
file.write(BulkUpload::LogToCsv.new(log: log_2, line_ending: "\r\n", col_offset: 0, overrides:).to_2022_csv_row) |
|
|
|
|
file.write(BulkUpload::LogToCsv.new(log: log_3, line_ending: "\r\n", col_offset: 0, overrides:).to_2022_csv_row) |
|
|
|
|
file.write(BulkUpload::LogToCsv.new(log: log_4, line_ending: "\r\n", col_offset: 0, overrides:).to_2022_csv_row) |
|
|
|
|
file.write(BulkUpload::LogToCsv.new(log: log_5, line_ending: "\r\n", col_offset: 0, overrides:).to_2022_csv_row) |
|
|
|
|
|
|
|
|
|
file.close |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
it "returns true" do |
|
|
|
|
validator.call |
|
|
|
|
expect(validator).to be_create_logs |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|