Browse Source

if dont know joint tenancy dont validate hhmemb (#1477)

pull/1342/head
Phil Lee 2 years ago committed by GitHub
parent
commit
02aa97e793
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      app/models/validations/tenancy_validations.rb
  2. 10
      spec/models/validations/tenancy_validations_spec.rb

2
app/models/validations/tenancy_validations.rb

@ -42,7 +42,7 @@ module Validations::TenancyValidations
def validate_joint_tenancy(record)
return unless record.collection_start_year && record.joint
if record.hhmemb == 1 && record.joint != 2 && record.collection_start_year >= 2022
if record.hhmemb == 1 && record.joint == 1 && record.collection_start_year >= 2022
record.errors.add :joint, :not_joint_tenancy, message: I18n.t("validations.tenancy.not_joint")
record.errors.add :hhmemb, I18n.t("validations.tenancy.joint_more_than_one_member")
end

10
spec/models/validations/tenancy_validations_spec.rb

@ -311,6 +311,16 @@ RSpec.describe Validations::TenancyValidations do
expect(record.errors["joint"]).to be_empty
expect(record.errors["hhmemb"]).to be_empty
end
it "does not error when don't know answer to joint" do
record.hhmemb = 1
record.joint = 3
tenancy_validator.validate_joint_tenancy(record)
expect(record.errors["joint"]).to be_empty
expect(record.errors["hhmemb"]).to be_empty
end
end
end
end

Loading…
Cancel
Save