|
|
|
|
@ -11,12 +11,6 @@ RSpec.describe BulkUpload::Lettings::Validator do
|
|
|
|
|
let(:file) { Tempfile.new } |
|
|
|
|
|
|
|
|
|
describe "validations" do |
|
|
|
|
context "when file is empty" do |
|
|
|
|
it "is not valid" do |
|
|
|
|
expect(validator).not_to be_valid |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
context "when 2022" do |
|
|
|
|
let(:bulk_upload) { create(:bulk_upload, user:, year: 2022) } |
|
|
|
|
|
|
|
|
|
@ -34,6 +28,13 @@ RSpec.describe BulkUpload::Lettings::Validator do
|
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
context "and is empty" do |
|
|
|
|
it "is not valid" do |
|
|
|
|
expect(validator).not_to be_valid |
|
|
|
|
expect(validator.errors["base"]).to eql(["Template is blank - The template must be filled in for us to create the logs and check if data is correct."]) |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
context "and doesn't have too many columns" do |
|
|
|
|
before do |
|
|
|
|
file.write(("a" * 95).chars.join(",")) |
|
|
|
|
@ -71,6 +72,13 @@ RSpec.describe BulkUpload::Lettings::Validator do
|
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
context "and is empty" do |
|
|
|
|
it "is not valid" do |
|
|
|
|
expect(validator).not_to be_valid |
|
|
|
|
expect(validator.errors["base"]).to eql(["Template is blank - The template must be filled in for us to create the logs and check if data is correct."]) |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
context "and file has too few valid headers" do |
|
|
|
|
let(:seed) { rand } |
|
|
|
|
let(:log_to_csv) { BulkUpload::LettingsLogToCsv.new(log:) } |
|
|
|
|
@ -128,6 +136,13 @@ RSpec.describe BulkUpload::Lettings::Validator do
|
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
context "and is empty" do |
|
|
|
|
it "is not valid" do |
|
|
|
|
expect(validator).not_to be_valid |
|
|
|
|
expect(validator.errors["base"]).to eql(["Template is blank - The template must be filled in for us to create the logs and check if data is correct."]) |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
context "and doesn't have too many columns" do |
|
|
|
|
before do |
|
|
|
|
file.write(("a" * 142).chars.join(",")) |
|
|
|
|
@ -142,6 +157,13 @@ RSpec.describe BulkUpload::Lettings::Validator do
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
context "when file has headers" do |
|
|
|
|
context "and is empty" do |
|
|
|
|
it "is not valid" do |
|
|
|
|
expect(validator).not_to be_valid |
|
|
|
|
expect(validator.errors["base"]).to eql(["Template is blank - The template must be filled in for us to create the logs and check if data is correct."]) |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
context "and file has extra invalid headers" do |
|
|
|
|
let(:seed) { rand } |
|
|
|
|
let(:log_to_csv) { BulkUpload::LettingsLogToCsv.new(log:) } |
|
|
|
|
|