Browse Source

Fix other reason for leaving last settled validation

pull/537/head
Ted 3 years ago
parent
commit
780f0892c4
  1. 2
      app/models/validations/household_validations.rb
  2. 4
      spec/models/validations/household_validations_spec.rb

2
app/models/validations/household_validations.rb

@ -18,7 +18,7 @@ module Validations::HouseholdValidations
record.errors.add :underoccupation_benefitcap, I18n.t("validations.household.underoccupation_benefitcap.dont_know_required")
record.errors.add :reason, I18n.t("validations.household.underoccupation_benefitcap.dont_know_required")
end
validate_other_field(record, 31, :reason, :reasonother)
validate_other_field(record, 20, :reason, :reasonother)
if record.is_reason_permanently_decanted? && record.referral.present? && !record.is_internal_transfer?
record.errors.add :referral, I18n.t("validations.household.referral.reason_permanently_decanted")

4
spec/models/validations/household_validations_spec.rb

@ -120,7 +120,7 @@ RSpec.describe Validations::HouseholdValidations do
let(:field) { "validations.other_field_missing" }
it "validates that a reason is provided" do
record.reason = 31
record.reason = 20
record.reasonother = nil
household_validator.validate_reason_for_leaving_last_settled_home(record)
expect(record.errors["reasonother"])
@ -128,7 +128,7 @@ RSpec.describe Validations::HouseholdValidations do
end
it "expects that a reason is provided" do
record.reason = 31
record.reason = 20
record.reasonother = "Some unusual reason"
household_validator.validate_reason_for_leaving_last_settled_home(record)
expect(record.errors["reasonother"]).to be_empty

Loading…
Cancel
Save