Browse Source

Only run net income validations when applicable_income_range exists

pull/2882/head
Kat 4 months ago
parent
commit
3ea47ffc39
  1. 4
      app/models/validations/soft_validations.rb
  2. 9
      spec/services/bulk_upload/lettings/year2024/row_parser_spec.rb

4
app/models/validations/soft_validations.rb

@ -16,13 +16,13 @@ module Validations::SoftValidations
}.freeze }.freeze
def net_income_in_soft_max_range? 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) weekly_net_income.between?(applicable_income_range.soft_max, applicable_income_range.hard_max)
end end
def net_income_in_soft_min_range? 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) weekly_net_income.between?(applicable_income_range.hard_min, applicable_income_range.soft_min)
end end

9
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.") 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
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 end
describe "log_already_exists?" do describe "log_already_exists?" do

Loading…
Cancel
Save