Browse Source

fix renewal mapping for bulk upload

pull/1148/head
Phil Lee 3 years ago
parent
commit
9f10fa90f1
  1. 11
      app/services/bulk_upload/lettings/row_parser.rb
  2. 16
      spec/services/bulk_upload/lettings/row_parser_spec.rb

11
app/services/bulk_upload/lettings/row_parser.rb

@ -353,7 +353,7 @@ private
attributes["postcode_full"] = postcode_full attributes["postcode_full"] = postcode_full
attributes["owning_organisation_id"] = owning_organisation_id attributes["owning_organisation_id"] = owning_organisation_id
attributes["managing_organisation_id"] = managing_organisation_id attributes["managing_organisation_id"] = managing_organisation_id
attributes["renewal"] = field_134 attributes["renewal"] = renewal
attributes["scheme"] = scheme attributes["scheme"] = scheme
attributes["created_by"] = bulk_upload.user attributes["created_by"] = bulk_upload.user
attributes["needstype"] = bulk_upload.needstype attributes["needstype"] = bulk_upload.needstype
@ -441,6 +441,15 @@ private
attributes attributes
end end
def renewal
case field_134
when 1
1
when 2
0
end
end
def hhmemb def hhmemb
[ [
person_2_present?, person_2_present?,

16
spec/services/bulk_upload/lettings/row_parser_spec.rb

@ -16,7 +16,7 @@ RSpec.describe BulkUpload::Lettings::RowParser do
field_96: "1", field_96: "1",
field_97: "1", field_97: "1",
field_98: "2023", field_98: "2023",
field_134: "0", field_134: "2",
} }
end end
@ -38,7 +38,7 @@ RSpec.describe BulkUpload::Lettings::RowParser do
describe "#valid?" do describe "#valid?" do
context "when calling the method multiple times" do context "when calling the method multiple times" do
let(:attributes) { { bulk_upload:, field_134: 3 } } let(:attributes) { { bulk_upload:, field_134: 2 } }
it "does not add keep adding errors to the pile" do it "does not add keep adding errors to the pile" do
expect { parser.valid? }.not_to change(parser.errors, :count) expect { parser.valid? }.not_to change(parser.errors, :count)
@ -60,7 +60,7 @@ RSpec.describe BulkUpload::Lettings::RowParser do
field_111: owning_org.old_visible_id, field_111: owning_org.old_visible_id,
field_113: managing_org.old_visible_id, field_113: managing_org.old_visible_id,
field_130: "1", field_130: "1",
field_134: "0", field_134: "2",
field_102: "2", field_102: "2",
field_103: "1", field_103: "1",
field_104: "1", field_104: "1",
@ -326,5 +326,15 @@ RSpec.describe BulkUpload::Lettings::RowParser do
end end
end end
end end
describe "#renewal" do
context "when field_134 is no ie 2" do
let(:attributes) { { bulk_upload:, field_134: 2 } }
it "sets value to 0" do
expect(parser.log.renewal).to eq(0)
end
end
end
end end
end end

Loading…
Cancel
Save