|
|
|
@ -12,6 +12,7 @@ RSpec.describe BulkUpload::Lettings::RowParser do |
|
|
|
let(:owning_org) { create(:organisation, :with_old_visible_id) } |
|
|
|
let(:owning_org) { create(:organisation, :with_old_visible_id) } |
|
|
|
let(:managing_org) { create(:organisation, :with_old_visible_id) } |
|
|
|
let(:managing_org) { create(:organisation, :with_old_visible_id) } |
|
|
|
let(:scheme) { create(:scheme, :with_old_visible_id, owning_organisation: owning_org) } |
|
|
|
let(:scheme) { create(:scheme, :with_old_visible_id, owning_organisation: owning_org) } |
|
|
|
|
|
|
|
let(:location) { create(:location, :with_old_visible_id, scheme:) } |
|
|
|
|
|
|
|
|
|
|
|
let(:setup_section_params) do |
|
|
|
let(:setup_section_params) do |
|
|
|
{ |
|
|
|
{ |
|
|
|
@ -330,6 +331,59 @@ RSpec.describe BulkUpload::Lettings::RowParser do |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
describe "#field_5" do |
|
|
|
|
|
|
|
context "when location does not exist" do |
|
|
|
|
|
|
|
let(:scheme) { create(:scheme, :with_old_visible_id, owning_organisation: owning_org) } |
|
|
|
|
|
|
|
let(:attributes) do |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
bulk_upload:, |
|
|
|
|
|
|
|
field_1: "1", |
|
|
|
|
|
|
|
field_4: scheme.old_visible_id, |
|
|
|
|
|
|
|
field_5: "dontexist", |
|
|
|
|
|
|
|
field_111: owning_org.old_visible_id, |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
it "returns an error" do |
|
|
|
|
|
|
|
expect(parser.errors[:field_5]).to be_present |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
context "when location exists" do |
|
|
|
|
|
|
|
let(:scheme) { create(:scheme, :with_old_visible_id, owning_organisation: owning_org) } |
|
|
|
|
|
|
|
let(:attributes) do |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
bulk_upload:, |
|
|
|
|
|
|
|
field_1: "1", |
|
|
|
|
|
|
|
field_4: scheme.old_visible_id, |
|
|
|
|
|
|
|
field_5: location.old_visible_id, |
|
|
|
|
|
|
|
field_111: owning_org.old_visible_id, |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
it "does not return an error" do |
|
|
|
|
|
|
|
expect(parser.errors[:field_5]).to be_blank |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
context "when location exists but not related" do |
|
|
|
|
|
|
|
let(:location) { create(:scheme, :with_old_visible_id) } |
|
|
|
|
|
|
|
let(:attributes) do |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
bulk_upload:, |
|
|
|
|
|
|
|
field_1: "1", |
|
|
|
|
|
|
|
field_4: scheme.old_visible_id, |
|
|
|
|
|
|
|
field_5: location.old_visible_id, |
|
|
|
|
|
|
|
field_111: owning_org.old_visible_id, |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
it "returns an error" do |
|
|
|
|
|
|
|
expect(parser.errors[:field_5]).to be_present |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
describe "#field_7" do |
|
|
|
describe "#field_7" do |
|
|
|
context "when null" do |
|
|
|
context "when null" do |
|
|
|
let(:attributes) { { bulk_upload:, field_7: nil } } |
|
|
|
let(:attributes) { { bulk_upload:, field_7: nil } } |
|
|
|
@ -620,6 +674,16 @@ RSpec.describe BulkUpload::Lettings::RowParser do |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
describe "#log" do |
|
|
|
describe "#log" do |
|
|
|
|
|
|
|
describe "#location" do |
|
|
|
|
|
|
|
context "when lookup is via new core id" do |
|
|
|
|
|
|
|
let(:attributes) { { bulk_upload:, field_4: scheme.old_visible_id, field_5: location.id, field_111: owning_org } } |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
it "assigns the correct location" do |
|
|
|
|
|
|
|
expect(parser.log.location).to eql(location) |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
describe "#scheme" do |
|
|
|
describe "#scheme" do |
|
|
|
context "when lookup is via id prefixed with S" do |
|
|
|
context "when lookup is via id prefixed with S" do |
|
|
|
let(:attributes) { { bulk_upload:, field_4: "S#{scheme.id}", field_111: owning_org } } |
|
|
|
let(:attributes) { { bulk_upload:, field_4: "S#{scheme.id}", field_111: owning_org } } |
|
|
|
|