Browse Source

CLDC-3971: Bug Q30 - Add error msg for hhmemb in shared housing scenario (#3034)

* Add validation error for hhmemb in shared housing scenario

* Update hhmemb validation message for shared housing scenario
pull/3056/head
Manny Dinssa 3 weeks ago committed by GitHub
parent
commit
865cdabf7a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 4
      app/models/validations/property_validations.rb
  2. 4
      config/locales/validations/lettings/property_information.en.yml
  3. 1
      spec/models/validations/property_validations_spec.rb

4
app/models/validations/property_validations.rb

@ -22,10 +22,10 @@ module Validations::PropertyValidations
def validate_shared_housing_rooms(record) def validate_shared_housing_rooms(record)
return unless record.unittype_gn return unless record.unittype_gn
if record.hhmemb == 1 && record.is_shared_housing? && if record.hhmemb == 1 && record.is_shared_housing? && !record.beds.to_i.between?(1, 3) && record.beds.present?
!record.beds.to_i.between?(1, 3) && record.beds.present?
record.errors.add :unittype_gn, I18n.t("validations.lettings.property.unittype_gn.one_three_bedroom_single_tenant_shared") record.errors.add :unittype_gn, I18n.t("validations.lettings.property.unittype_gn.one_three_bedroom_single_tenant_shared")
record.errors.add :beds, :one_three_bedroom_single_tenant_shared, message: I18n.t("validations.lettings.property.beds.one_three_bedroom_single_tenant_shared") record.errors.add :beds, :one_three_bedroom_single_tenant_shared, message: I18n.t("validations.lettings.property.beds.one_three_bedroom_single_tenant_shared")
record.errors.add :hhmemb, I18n.t("validations.lettings.property.hhmemb.one_three_bedroom_single_tenant_shared")
elsif record.is_shared_housing? && record.beds.present? && !record.beds.to_i.between?(1, 7) elsif record.is_shared_housing? && record.beds.present? && !record.beds.to_i.between?(1, 7)
record.errors.add :unittype_gn, I18n.t("validations.lettings.property.unittype_gn.one_seven_bedroom_shared") record.errors.add :unittype_gn, I18n.t("validations.lettings.property.unittype_gn.one_seven_bedroom_shared")
record.errors.add :beds, I18n.t("validations.lettings.property.beds.one_seven_bedroom_shared") record.errors.add :beds, I18n.t("validations.lettings.property.beds.one_seven_bedroom_shared")

4
config/locales/validations/lettings/property_information.en.yml

@ -17,6 +17,8 @@ en:
beds: beds:
one_three_bedroom_single_tenant_shared: "A shared house with fewer than two tenants must have 1 to 3 bedrooms." one_three_bedroom_single_tenant_shared: "A shared house with fewer than two tenants must have 1 to 3 bedrooms."
one_seven_bedroom_shared: "A shared house must have 1 to 7 bedrooms." one_seven_bedroom_shared: "A shared house must have 1 to 7 bedrooms."
hhmemb:
one_three_bedroom_single_tenant_shared: "A shared house with more than 3 bedrooms cannot have fewer than two tenants."
uprn: uprn:
invalid: "UPRN must be 12 digits or less." invalid: "UPRN must be 12 digits or less."
not_in_england: "It looks like you have entered an address outside of England. Only create logs for lettings in England." not_in_england: "It looks like you have entered an address outside of England. Only create logs for lettings in England."
@ -30,7 +32,7 @@ en:
not_in_england: "This scheme’s only location is outside of England. Only create logs for lettings in England." not_in_england: "This scheme’s only location is outside of England. Only create logs for lettings in England."
location_id: location_id:
not_in_england: "It looks like you have selected a location outside of England. Only create logs for lettings in England." not_in_england: "It looks like you have selected a location outside of England. Only create logs for lettings in England."
startdate: startdate:
postcode_not_in_england: "It looks like you have an entered a postcode outside of England. Only create logs for lettings in England." postcode_not_in_england: "It looks like you have an entered a postcode outside of England. Only create logs for lettings in England."
address_not_in_england: "It looks like you have entered an address outside of England. Only create logs for lettings in England." address_not_in_england: "It looks like you have entered an address outside of England. Only create logs for lettings in England."
location_not_in_england: "It looks like you have selected a location outside of England. Only create logs for lettings in England." location_not_in_england: "It looks like you have selected a location outside of England. Only create logs for lettings in England."

1
spec/models/validations/property_validations_spec.rb

@ -85,6 +85,7 @@ RSpec.describe Validations::PropertyValidations do
property_validator.validate_shared_housing_rooms(log) property_validator.validate_shared_housing_rooms(log)
expect(log.errors["unittype_gn"]).to include(match(expected_error)) expect(log.errors["unittype_gn"]).to include(match(expected_error))
expect(log.errors["beds"]).to include(I18n.t("validations.lettings.property.unittype_gn.one_three_bedroom_single_tenant_shared")) expect(log.errors["beds"]).to include(I18n.t("validations.lettings.property.unittype_gn.one_three_bedroom_single_tenant_shared"))
expect(log.errors["hhmemb"]).to include(I18n.t("validations.lettings.property.hhmemb.one_three_bedroom_single_tenant_shared"))
end end
end end
end end

Loading…
Cancel
Save