diff --git a/app/models/form/lettings/questions/address_line1.rb b/app/models/form/lettings/questions/address_line1.rb index 2f88b210e..c96e8db1e 100644 --- a/app/models/form/lettings/questions/address_line1.rb +++ b/app/models/form/lettings/questions/address_line1.rb @@ -18,5 +18,11 @@ class Form::Lettings::Questions::AddressLine1 < ::Form::Question ].select(&:present?).join("\n") end + def unanswered_error_message(log = nil) + return super unless log&.is_supported_housing? + + I18n.t("validations.lettings.property.address_line1.not_answered_supported_housing") + end + QUESTION_NUMBER_FROM_YEAR = { 2023 => 12, 2024 => 13, 2025 => 17, 2026 => 17 }.freeze end diff --git a/config/locales/validations/lettings/property_information.en.yml b/config/locales/validations/lettings/property_information.en.yml index e40b92f64..5de2ad613 100644 --- a/config/locales/validations/lettings/property_information.en.yml +++ b/config/locales/validations/lettings/property_information.en.yml @@ -4,6 +4,8 @@ en: property: address: not_answered_supported_housing: "You must enter address. If your letting is in a confidential scheme, please check the scheme you chose in the ‘Set up this lettings log’ section. If a scheme needs updating to mark it as confidential, a CORE coordinator in your organisation can do this." + address_line1: + not_answered_supported_housing: "You must enter address line 1. If your letting is in a confidential scheme, please check the scheme you chose in the ‘Set up this lettings log’ section. If a scheme needs updating to mark it as confidential, a CORE coordinator in your organisation can do this." postcode_full: invalid: "Enter a postcode in the correct format, for example AA1 1AA." not_in_england: "It looks like you have an entered a postcode outside of England. Only create logs for lettings in England." diff --git a/spec/models/form/lettings/questions/address_line1_spec.rb b/spec/models/form/lettings/questions/address_line1_spec.rb index 212e3be9b..ce4903c0d 100644 --- a/spec/models/form/lettings/questions/address_line1_spec.rb +++ b/spec/models/form/lettings/questions/address_line1_spec.rb @@ -38,4 +38,34 @@ RSpec.describe Form::Lettings::Questions::AddressLine1, type: :model do it "has the correct check_answers_card_number" do expect(question.check_answers_card_number).to be_nil end + + describe "#unanswered_error_message" do + context "when the log is supported housing" do + let(:log) { build(:lettings_log, needstype: 2) } + + it "returns the confidential-scheme guidance message" do + expect(question.unanswered_error_message(log)).to eq( + "You must enter address line 1. If your letting is in a confidential scheme, please check the scheme you chose in the ‘Set up this lettings log’ section. If a scheme needs updating to mark it as confidential, a CORE coordinator in your organisation can do this.", + ) + end + end + + context "when the log is general needs" do + let(:log) { build(:lettings_log, needstype: 1) } + + it "returns the default unanswered message" do + expect(question.unanswered_error_message(log)).to eq( + I18n.t("validations.not_answered", question: question.error_display_label.downcase), + ) + end + end + + context "when no log is given" do + it "returns the default unanswered message" do + expect(question.unanswered_error_message).to eq( + I18n.t("validations.not_answered", question: question.error_display_label.downcase), + ) + end + end + end end