Browse Source

Only run 103 validation for shared ownership (#2289)

pull/2278/head^2
kosiakkatrina 10 months ago committed by GitHub
parent
commit
48a18627c4
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 2
      app/services/bulk_upload/sales/year2024/row_parser.rb
  2. 16
      spec/services/bulk_upload/sales/year2024/row_parser_spec.rb

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

@ -344,7 +344,7 @@ class BulkUpload::Sales::Year2024::RowParser
validates :field_103, validates :field_103,
inclusion: { inclusion: {
in: [1, 2], in: [1, 2],
if: proc { field_88 != 100 }, if: proc { field_88.present? && field_88 != 100 && shared_ownership? },
question: QUESTIONS[:field_103], question: QUESTIONS[:field_103],
}, },
on: :before_log on: :before_log

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

@ -1005,6 +1005,22 @@ RSpec.describe BulkUpload::Sales::Year2024::RowParser do
end end
end end
context "when value is 3 and stairowned is not answered" do
let(:attributes) { setup_section_params.merge(field_103: "3", field_86: "1", field_87: "50", field_88: nil, field_109: nil) }
it "does not add errors" do
expect(parser.errors[:field_103]).not_to include("Enter a valid value for Was a mortgage used for the purchase of this property? - Shared ownership")
end
end
context "when it's not shared ownership" do
let(:attributes) { setup_section_params.merge(field_8: "2", field_103: "3", field_86: "1", field_87: "50", field_88: "99", field_109: nil) }
it "does not add errors" do
expect(parser.errors[:field_103]).not_to include("Enter a valid value for Was a mortgage used for the purchase of this property? - Shared ownership")
end
end
context "when value is 3 and stairowned is 100" do context "when value is 3 and stairowned is 100" do
let(:attributes) { setup_section_params.merge(field_103: "3", field_86: "1", field_87: "50", field_88: "100", field_109: nil) } let(:attributes) { setup_section_params.merge(field_103: "3", field_86: "1", field_87: "50", field_88: "100", field_109: nil) }

Loading…
Cancel
Save