diff --git a/app/services/bulk_upload/lettings/year2024/row_parser.rb b/app/services/bulk_upload/lettings/year2024/row_parser.rb index e03fd4817..8b5fe8f3c 100644 --- a/app/services/bulk_upload/lettings/year2024/row_parser.rb +++ b/app/services/bulk_upload/lettings/year2024/row_parser.rb @@ -1192,7 +1192,7 @@ private attributes["layear"] = field_96 attributes["waityear"] = field_97 attributes["reason"] = field_98 - attributes["reasonother"] = field_99 + attributes["reasonother"] = field_99 if reason_is_other? attributes["prevten"] = field_100 attributes["homeless"] = field_101 @@ -1570,4 +1570,8 @@ private def is_carehome field_124.present? ? 1 : 0 end + + def reason_is_other? + field_98 == 20 + end end diff --git a/spec/services/bulk_upload/lettings/year2024/row_parser_spec.rb b/spec/services/bulk_upload/lettings/year2024/row_parser_spec.rb index cd398dabd..f99052d99 100644 --- a/spec/services/bulk_upload/lettings/year2024/row_parser_spec.rb +++ b/spec/services/bulk_upload/lettings/year2024/row_parser_spec.rb @@ -2223,10 +2223,20 @@ RSpec.describe BulkUpload::Lettings::Year2024::RowParser do end 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 - expect(parser.log.reasonother).to eql("some other reason") + it "is set to given free text string" do + expect(parser.log.reasonother).to eql("some other reason") + 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