Browse Source

Add error message to the date

pull/2763/head
Kat 9 months ago
parent
commit
9b38fb337c
  1. 2
      app/models/validations/property_validations.rb
  2. 1
      app/models/validations/sales/property_validations.rb
  3. 2
      config/locales/validations/lettings/property_information.en.yml
  4. 2
      config/locales/validations/sales/property_information.en.yml
  5. 3
      spec/models/validations/property_validations_spec.rb
  6. 3
      spec/models/validations/sales/property_validations_spec.rb

2
app/models/validations/property_validations.rb

@ -59,12 +59,14 @@ module Validations::PropertyValidations
record.errors.add :uprn, I18n.t("validations.lettings.property.uprn.not_in_england") record.errors.add :uprn, I18n.t("validations.lettings.property.uprn.not_in_england")
record.errors.add :uprn_confirmation, I18n.t("validations.lettings.property.uprn_confirmation.not_in_england") record.errors.add :uprn_confirmation, I18n.t("validations.lettings.property.uprn_confirmation.not_in_england")
record.errors.add :uprn_selection, I18n.t("validations.lettings.property.uprn_selection.not_in_england") record.errors.add :uprn_selection, I18n.t("validations.lettings.property.uprn_selection.not_in_england")
record.errors.add :startdate, I18n.t("validations.lettings.property.startdate.not_in_england")
elsif record.is_supported_housing? elsif record.is_supported_housing?
return unless record.location return unless record.location
return if record.location.location_code.in?(LocalAuthority.england.pluck(:code)) return if record.location.location_code.in?(LocalAuthority.england.pluck(:code))
record.errors.add :location_id, I18n.t("validations.lettings.property.location_id.not_in_england") record.errors.add :location_id, I18n.t("validations.lettings.property.location_id.not_in_england")
record.errors.add :scheme_id, I18n.t("validations.lettings.property.scheme_id.not_in_england") record.errors.add :scheme_id, I18n.t("validations.lettings.property.scheme_id.not_in_england")
record.errors.add :startdate, I18n.t("validations.lettings.property.startdate.not_in_england")
end end
end end
end end

1
app/models/validations/sales/property_validations.rb

@ -46,5 +46,6 @@ module Validations::Sales::PropertyValidations
record.errors.add :uprn, I18n.t("validations.sales.property_information.uprn.not_in_england") record.errors.add :uprn, I18n.t("validations.sales.property_information.uprn.not_in_england")
record.errors.add :uprn_confirmation, I18n.t("validations.sales.property_information.uprn_confirmation.not_in_england") record.errors.add :uprn_confirmation, I18n.t("validations.sales.property_information.uprn_confirmation.not_in_england")
record.errors.add :uprn_selection, I18n.t("validations.sales.property_information.uprn_selection.not_in_england") record.errors.add :uprn_selection, I18n.t("validations.sales.property_information.uprn_selection.not_in_england")
record.errors.add :saledate, I18n.t("validations.sales.property_information.saledate.not_in_england")
end end
end end

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

@ -30,3 +30,5 @@ en:
not_in_england: "It looks like you have selected a location with a local authority outside of England - only submit Lettings forms for Lettings that occur in England" not_in_england: "It looks like you have selected a location with a local authority outside of England - only submit Lettings forms for Lettings that occur in England"
location_id: location_id:
not_in_england: "It looks like you have selected a location with a local authority outside of England - only submit Lettings forms for Lettings that occur in England" not_in_england: "It looks like you have selected a location with a local authority outside of England - only submit Lettings forms for Lettings that occur in England"
startdate:
not_in_england: "It looks like you have selected a local authority outside of England - only submit Lettings forms for Lettings that occur in England"

2
config/locales/validations/sales/property_information.en.yml

@ -34,3 +34,5 @@ en:
not_in_england: "It looks like you have entered a UPRN for a local authority outside of England - only submit Sales forms for Sales that occur in England" not_in_england: "It looks like you have entered a UPRN for a local authority outside of England - only submit Sales forms for Sales that occur in England"
uprn_selection: uprn_selection:
not_in_england: "It looks like you have selected an address for a local authority outside of England - only submit Sales forms for Sales that occur in England" not_in_england: "It looks like you have selected an address for a local authority outside of England - only submit Sales forms for Sales that occur in England"
saledate:
not_in_england: "It looks like you have selected a local authority outside of England - only submit Sales forms for Sales that occur in England"

3
spec/models/validations/property_validations_spec.rb

@ -221,6 +221,7 @@ RSpec.describe Validations::PropertyValidations do
expect(log.errors["uprn"]).to include(I18n.t("validations.lettings.property.uprn.not_in_england")) expect(log.errors["uprn"]).to include(I18n.t("validations.lettings.property.uprn.not_in_england"))
expect(log.errors["uprn_confirmation"]).to include(I18n.t("validations.lettings.property.uprn_confirmation.not_in_england")) expect(log.errors["uprn_confirmation"]).to include(I18n.t("validations.lettings.property.uprn_confirmation.not_in_england"))
expect(log.errors["uprn_selection"]).to include(I18n.t("validations.lettings.property.uprn_selection.not_in_england")) expect(log.errors["uprn_selection"]).to include(I18n.t("validations.lettings.property.uprn_selection.not_in_england"))
expect(log.errors["startdate"]).to include(I18n.t("validations.lettings.property.startdate.not_in_england"))
expect(log.errors["scheme_id"]).to be_empty expect(log.errors["scheme_id"]).to be_empty
expect(log.errors["location_id"]).to be_empty expect(log.errors["location_id"]).to be_empty
end end
@ -234,6 +235,7 @@ RSpec.describe Validations::PropertyValidations do
property_validator.validate_la_in_england(log) property_validator.validate_la_in_england(log)
expect(log.errors["scheme_id"]).to include(I18n.t("validations.lettings.property.scheme_id.not_in_england")) expect(log.errors["scheme_id"]).to include(I18n.t("validations.lettings.property.scheme_id.not_in_england"))
expect(log.errors["location_id"]).to include(I18n.t("validations.lettings.property.location_id.not_in_england")) expect(log.errors["location_id"]).to include(I18n.t("validations.lettings.property.location_id.not_in_england"))
expect(log.errors["startdate"]).to include(I18n.t("validations.lettings.property.startdate.not_in_england"))
expect(log.errors["la"]).to be_empty expect(log.errors["la"]).to be_empty
expect(log.errors["postcode_full"]).to be_empty expect(log.errors["postcode_full"]).to be_empty
expect(log.errors["uprn"]).to be_empty expect(log.errors["uprn"]).to be_empty
@ -252,6 +254,7 @@ RSpec.describe Validations::PropertyValidations do
expect(log.errors["uprn"]).to be_empty expect(log.errors["uprn"]).to be_empty
expect(log.errors["uprn_confirmation"]).to be_empty expect(log.errors["uprn_confirmation"]).to be_empty
expect(log.errors["uprn_selection"]).to be_empty expect(log.errors["uprn_selection"]).to be_empty
expect(log.errors["startdate"]).to be_empty
end end
end end
end end

3
spec/models/validations/sales/property_validations_spec.rb

@ -159,6 +159,7 @@ RSpec.describe Validations::Sales::PropertyValidations do
expect(log.errors["uprn"]).to include(I18n.t("validations.sales.property_information.uprn.not_in_england")) expect(log.errors["uprn"]).to include(I18n.t("validations.sales.property_information.uprn.not_in_england"))
expect(log.errors["uprn_confirmation"]).to include(I18n.t("validations.sales.property_information.uprn_confirmation.not_in_england")) expect(log.errors["uprn_confirmation"]).to include(I18n.t("validations.sales.property_information.uprn_confirmation.not_in_england"))
expect(log.errors["uprn_selection"]).to include(I18n.t("validations.sales.property_information.uprn_selection.not_in_england")) expect(log.errors["uprn_selection"]).to include(I18n.t("validations.sales.property_information.uprn_selection.not_in_england"))
expect(log.errors["saledate"]).to include(I18n.t("validations.sales.property_information.saledate.not_in_england"))
end end
end end
@ -172,6 +173,7 @@ RSpec.describe Validations::Sales::PropertyValidations do
expect(log.errors["uprn"]).to be_empty expect(log.errors["uprn"]).to be_empty
expect(log.errors["uprn_confirmation"]).to be_empty expect(log.errors["uprn_confirmation"]).to be_empty
expect(log.errors["uprn_selection"]).to be_empty expect(log.errors["uprn_selection"]).to be_empty
expect(log.errors["saledate"]).to be_empty
end end
end end
end end
@ -191,6 +193,7 @@ RSpec.describe Validations::Sales::PropertyValidations do
expect(log.errors["uprn"]).to be_empty expect(log.errors["uprn"]).to be_empty
expect(log.errors["uprn_confirmation"]).to be_empty expect(log.errors["uprn_confirmation"]).to be_empty
expect(log.errors["uprn_selection"]).to be_empty expect(log.errors["uprn_selection"]).to be_empty
expect(log.errors["saledate"]).to be_empty
end end
end end
end end

Loading…
Cancel
Save