Browse Source

CLDC-3279: Ignore reasonother field in bulk upload if reason is not other (#2291)

CLDC-3305-postcode-routing
Rachael Booth 1 year ago committed by GitHub
parent
commit
daa817c574
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 6
      app/services/bulk_upload/lettings/year2024/row_parser.rb
  2. 14
      spec/services/bulk_upload/lettings/year2024/row_parser_spec.rb

6
app/services/bulk_upload/lettings/year2024/row_parser.rb

@ -1192,7 +1192,7 @@ private
attributes["layear"] = field_96 attributes["layear"] = field_96
attributes["waityear"] = field_97 attributes["waityear"] = field_97
attributes["reason"] = field_98 attributes["reason"] = field_98
attributes["reasonother"] = field_99 attributes["reasonother"] = field_99 if reason_is_other?
attributes["prevten"] = field_100 attributes["prevten"] = field_100
attributes["homeless"] = field_101 attributes["homeless"] = field_101
@ -1570,4 +1570,8 @@ private
def is_carehome def is_carehome
field_124.present? ? 1 : 0 field_124.present? ? 1 : 0
end end
def reason_is_other?
field_98 == 20
end
end end

14
spec/services/bulk_upload/lettings/year2024/row_parser_spec.rb

@ -2223,13 +2223,23 @@ RSpec.describe BulkUpload::Lettings::Year2024::RowParser do
end end
describe "#reasonother" do describe "#reasonother" do
let(:attributes) { { bulk_upload:, field_99: "some other reason" } } context "when reason is 'other'" do
let(:attributes) { { bulk_upload:, field_98: "20", field_99: "some other reason" } }
it "sets value to given free text string" do it "is set to given free text string" do
expect(parser.log.reasonother).to eql("some other reason") expect(parser.log.reasonother).to eql("some other reason")
end end
end end
context "when reason is not 'other'" do
let(:attributes) { { bulk_upload:, field_98: "50", field_99: "some other reason" } }
it "is set to nil" do
expect(parser.log.reasonother).to be_nil
end
end
end
describe "#ppcodenk" do describe "#ppcodenk" do
let(:attributes) { { bulk_upload:, field_102: "2" } } let(:attributes) { { bulk_upload:, field_102: "2" } }

Loading…
Cancel
Save