Browse Source

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

CLDC-3305-postcode-routing
Rachael Booth 10 months 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. 16
      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["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

16
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

Loading…
Cancel
Save