|
|
|
@ -558,12 +558,12 @@ RSpec.describe BulkUpload::Lettings::RowParser do |
|
|
|
context "when all of these fields are blank" do |
|
|
|
context "when all of these fields are blank" do |
|
|
|
let(:attributes) { { bulk_upload:, field_1: "1", field_96: nil, field_97: nil, field_98: nil } } |
|
|
|
let(:attributes) { { bulk_upload:, field_1: "1", field_96: nil, field_97: nil, field_98: nil } } |
|
|
|
|
|
|
|
|
|
|
|
it "returns an error" do |
|
|
|
it "returns them as setup errors" do |
|
|
|
parser.valid? |
|
|
|
setup_errors = parser.errors.select { |e| e.options[:category] == :setup } |
|
|
|
|
|
|
|
|
|
|
|
expect(parser.errors[:field_96]).to be_present |
|
|
|
expect(setup_errors.find { |e| e.attribute == :field_96 }).to be_present |
|
|
|
expect(parser.errors[:field_97]).to be_present |
|
|
|
expect(setup_errors.find { |e| e.attribute == :field_97 }).to be_present |
|
|
|
expect(parser.errors[:field_98]).to be_present |
|
|
|
expect(setup_errors.find { |e| e.attribute == :field_98 }).to be_present |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
@ -571,8 +571,6 @@ RSpec.describe BulkUpload::Lettings::RowParser do |
|
|
|
let(:attributes) { { bulk_upload:, field_1: "1", field_96: "1", field_97: "1", field_98: nil } } |
|
|
|
let(:attributes) { { bulk_upload:, field_1: "1", field_96: "1", field_97: "1", field_98: nil } } |
|
|
|
|
|
|
|
|
|
|
|
it "returns an error only on blank field" do |
|
|
|
it "returns an error only on blank field" do |
|
|
|
parser.valid? |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
expect(parser.errors[:field_96]).to be_blank |
|
|
|
expect(parser.errors[:field_96]).to be_blank |
|
|
|
expect(parser.errors[:field_97]).to be_blank |
|
|
|
expect(parser.errors[:field_97]).to be_blank |
|
|
|
expect(parser.errors[:field_98]).to be_present |
|
|
|
expect(parser.errors[:field_98]).to be_present |
|
|
|
@ -583,8 +581,6 @@ RSpec.describe BulkUpload::Lettings::RowParser do |
|
|
|
let(:attributes) { { bulk_upload:, field_98: "2022" } } |
|
|
|
let(:attributes) { { bulk_upload:, field_98: "2022" } } |
|
|
|
|
|
|
|
|
|
|
|
it "returns an error" do |
|
|
|
it "returns an error" do |
|
|
|
parser.valid? |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
expect(parser.errors[:field_98]).to include("Tenancy start year must be 2 digits") |
|
|
|
expect(parser.errors[:field_98]).to include("Tenancy start year must be 2 digits") |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
@ -603,8 +599,6 @@ RSpec.describe BulkUpload::Lettings::RowParser do |
|
|
|
let(:bulk_upload) { create(:bulk_upload, :lettings, user:, year: 2022) } |
|
|
|
let(:bulk_upload) { create(:bulk_upload, :lettings, user:, year: 2022) } |
|
|
|
|
|
|
|
|
|
|
|
it "does not return errors" do |
|
|
|
it "does not return errors" do |
|
|
|
parser.valid? |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
expect(parser.errors[:field_96]).not_to be_present |
|
|
|
expect(parser.errors[:field_96]).not_to be_present |
|
|
|
expect(parser.errors[:field_97]).not_to be_present |
|
|
|
expect(parser.errors[:field_97]).not_to be_present |
|
|
|
expect(parser.errors[:field_98]).not_to be_present |
|
|
|
expect(parser.errors[:field_98]).not_to be_present |
|
|
|
@ -623,8 +617,6 @@ RSpec.describe BulkUpload::Lettings::RowParser do |
|
|
|
let(:bulk_upload) { create(:bulk_upload, :lettings, user:, year: 2022) } |
|
|
|
let(:bulk_upload) { create(:bulk_upload, :lettings, user:, year: 2022) } |
|
|
|
|
|
|
|
|
|
|
|
it "returns errors" do |
|
|
|
it "returns errors" do |
|
|
|
parser.valid? |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
expect(parser.errors[:field_96]).to be_present |
|
|
|
expect(parser.errors[:field_96]).to be_present |
|
|
|
expect(parser.errors[:field_97]).to be_present |
|
|
|
expect(parser.errors[:field_97]).to be_present |
|
|
|
expect(parser.errors[:field_98]).to be_present |
|
|
|
expect(parser.errors[:field_98]).to be_present |
|
|
|
|