diff --git a/app/validations/soft_validations.rb b/app/validations/soft_validations.rb index 451988b66..8fb5165c7 100644 --- a/app/validations/soft_validations.rb +++ b/app/validations/soft_validations.rb @@ -40,6 +40,6 @@ private def net_income_in_soft_min_range? return unless weekly_net_income && ecstat1 - weekly_net_income.between?(applicable_income_range.soft_min, applicable_income_range.hard_min) + weekly_net_income.between?(applicable_income_range.hard_min, applicable_income_range.soft_min) end end diff --git a/spec/factories/case_log.rb b/spec/factories/case_log.rb index 985d89073..ee791b1fc 100644 --- a/spec/factories/case_log.rb +++ b/spec/factories/case_log.rb @@ -60,7 +60,7 @@ FactoryBot.define do property_void_date { "03/11/2019" } offered { 2 } wchair { "Yes" } - earnings { 60 } + earnings { 68 } incfreq { "Weekly" } benefits { "Some" } period { "Fortnightly" } diff --git a/spec/models/case_log_spec.rb b/spec/models/case_log_spec.rb index 1c265f59a..ebdcf51df 100644 --- a/spec/models/case_log_spec.rb +++ b/spec/models/case_log_spec.rb @@ -324,6 +324,36 @@ RSpec.describe Form, type: :model do ) }.to raise_error(ActiveRecord::RecordInvalid) end + + context "given an income in upper soft validation range" do + let(:case_log) do + FactoryBot.create(:case_log, + ecstat1: "Full-time - 30 hours or more", + earnings: 750, + incfreq: "Weekly") + end + + it "updates soft errors" do + expect(case_log.has_no_unresolved_soft_errors?).to be false + expect(case_log.soft_errors["override_net_income_validation"].message) + .to match(/Net income is higher than expected/) + end + end + + context "given an income in lower soft validation range" do + let(:case_log) do + FactoryBot.create(:case_log, + ecstat1: "Full-time - 30 hours or more", + earnings: 120, + incfreq: "Weekly") + end + + it "updates soft errors" do + expect(case_log.has_no_unresolved_soft_errors?).to be false + expect(case_log.soft_errors["override_net_income_validation"].message) + .to match(/Net income is lower than expected/) + end + end end end