Browse Source

Explicitly ensure soctenant nil for non shared ownership in bulk upload

pull/2200/head
Rachael Booth 2 years ago
parent
commit
3f69e1a683
  1. 2
      app/services/bulk_upload/sales/year2024/row_parser.rb
  2. 26
      spec/services/bulk_upload/sales/year2024/row_parser_spec.rb

2
app/services/bulk_upload/sales/year2024/row_parser.rb

@ -1119,6 +1119,8 @@ private
end end
def infer_soctenant_from_prevten_and_prevtenbuy2 def infer_soctenant_from_prevten_and_prevtenbuy2
return unless shared_ownership?
if [1, 2].include?(field_61) || [1, 2].include?(field_71.to_i) if [1, 2].include?(field_61) || [1, 2].include?(field_71.to_i)
1 1
else else

26
spec/services/bulk_upload/sales/year2024/row_parser_spec.rb

@ -1136,8 +1136,25 @@ RSpec.describe BulkUpload::Sales::Year2024::RowParser do
end end
describe "#soctenant" do describe "#soctenant" do
context "when discounted ownership" do
let(:attributes) { valid_attributes.merge({ field_8: "2" }) }
it "is set to nil" do
expect(parser.log.soctenant).to be_nil
end
end
context "when outright sale" do
let(:attributes) { valid_attributes.merge({ field_8: "3" }) }
it "is set to nil" do
expect(parser.log.soctenant).to be_nil
end
end
context "when shared ownership" do
context "when prevten is a social housing type" do context "when prevten is a social housing type" do
let(:attributes) { valid_attributes.merge({ field_61: "1" }) } let(:attributes) { valid_attributes.merge({ field_8: "1", field_61: "1" }) }
it "is set to yes" do it "is set to yes" do
expect(parser.log.soctenant).to be(1) expect(parser.log.soctenant).to be(1)
@ -1146,7 +1163,7 @@ RSpec.describe BulkUpload::Sales::Year2024::RowParser do
context "when prevten is not a social housing type" do context "when prevten is not a social housing type" do
context "and prevtenbuy2 is a social housing type" do context "and prevtenbuy2 is a social housing type" do
let(:attributes) { valid_attributes.merge({ field_61: "3", field_71: "2" }) } let(:attributes) { valid_attributes.merge({ field_8: "1", field_61: "3", field_71: "2" }) }
it "is set to yes" do it "is set to yes" do
expect(parser.log.soctenant).to be(1) expect(parser.log.soctenant).to be(1)
@ -1154,7 +1171,7 @@ RSpec.describe BulkUpload::Sales::Year2024::RowParser do
end end
context "and prevtenbuy2 is not a social housing type" do context "and prevtenbuy2 is not a social housing type" do
let(:attributes) { valid_attributes.merge({ field_61: "3", field_71: "4" }) } let(:attributes) { valid_attributes.merge({ field_8: "1", field_61: "3", field_71: "4" }) }
it "is set to no" do it "is set to no" do
expect(parser.log.soctenant).to be(2) expect(parser.log.soctenant).to be(2)
@ -1162,7 +1179,7 @@ RSpec.describe BulkUpload::Sales::Year2024::RowParser do
end end
context "and prevtenbuy2 is blank" do context "and prevtenbuy2 is blank" do
let(:attributes) { valid_attributes.merge({ field_61: "3", field_71: nil }) } let(:attributes) { valid_attributes.merge({ field_8: "1", field_61: "3", field_71: nil }) }
it "is set to no" do it "is set to no" do
expect(parser.log.soctenant).to be(2) expect(parser.log.soctenant).to be(2)
@ -1170,6 +1187,7 @@ RSpec.describe BulkUpload::Sales::Year2024::RowParser do
end end
end end
end end
end
describe "with living before purchase years for shared ownership more than 0" do describe "with living before purchase years for shared ownership more than 0" do
let(:attributes) { setup_section_params.merge({ field_8: "1", field_85: "1" }) } let(:attributes) { setup_section_params.merge({ field_8: "1", field_85: "1" }) }

Loading…
Cancel
Save