From 3ea47ffc398dcd21fa2bd6501e73c2f5647f0861 Mon Sep 17 00:00:00 2001 From: Kat <54268893+kosiakkatrina@users.noreply.github.com> Date: Fri, 3 Jan 2025 15:13:33 +0000 Subject: [PATCH] Only run net income validations when applicable_income_range exists --- app/models/validations/soft_validations.rb | 4 ++-- .../bulk_upload/lettings/year2024/row_parser_spec.rb | 9 +++++++++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/app/models/validations/soft_validations.rb b/app/models/validations/soft_validations.rb index 1a2c61138..9dc8828e8 100644 --- a/app/models/validations/soft_validations.rb +++ b/app/models/validations/soft_validations.rb @@ -16,13 +16,13 @@ module Validations::SoftValidations }.freeze def net_income_in_soft_max_range? - return unless weekly_net_income && ecstat1 && hhmemb + return unless weekly_net_income && ecstat1 && hhmemb && applicable_income_range weekly_net_income.between?(applicable_income_range.soft_max, applicable_income_range.hard_max) end def net_income_in_soft_min_range? - return unless weekly_net_income && ecstat1 && hhmemb + return unless weekly_net_income && ecstat1 && hhmemb && applicable_income_range weekly_net_income.between?(applicable_income_range.hard_min, applicable_income_range.soft_min) 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 357d661b7..01529a80b 100644 --- a/spec/services/bulk_upload/lettings/year2024/row_parser_spec.rb +++ b/spec/services/bulk_upload/lettings/year2024/row_parser_spec.rb @@ -1915,6 +1915,15 @@ RSpec.describe BulkUpload::Lettings::Year2024::RowParser do expect(parser.errors.where(:field_125, category: :soft_validation).first.message).to eql("You told us the rent is £120.00 every week. This is higher than we would expect.") end end + + context "when an invalid ecstat1 is given" do + let(:attributes) { setup_section_params.merge({ field_46: 11, field_119: 123, field_118: 1 }) } + + it "does not run net income soft validations validation" do + parser.valid? + expect(parser.errors.where(:field_46).count).to be(1) + end + end end describe "log_already_exists?" do