Browse Source

Net income range soft validation fix

pull/111/head
baarkerlounger 3 years ago
parent
commit
8cac41c494
  1. 2
      app/validations/soft_validations.rb
  2. 2
      spec/factories/case_log.rb
  3. 30
      spec/models/case_log_spec.rb

2
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

2
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" }

30
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

Loading…
Cancel
Save