Browse Source

Add supported housing only error message to Q17

CLDC-4461-hide-confidential-addresses
oscric 2 days ago
parent
commit
4232e79102
  1. 6
      app/models/form/lettings/questions/address_line1.rb
  2. 2
      config/locales/validations/lettings/property_information.en.yml
  3. 30
      spec/models/form/lettings/questions/address_line1_spec.rb

6
app/models/form/lettings/questions/address_line1.rb

@ -18,5 +18,11 @@ class Form::Lettings::Questions::AddressLine1 < ::Form::Question
].select(&:present?).join("\n") ].select(&:present?).join("\n")
end 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 QUESTION_NUMBER_FROM_YEAR = { 2023 => 12, 2024 => 13, 2025 => 17, 2026 => 17 }.freeze
end end

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

@ -4,6 +4,8 @@ en:
property: property:
address: 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." 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: postcode_full:
invalid: "Enter a postcode in the correct format, for example AA1 1AA." 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." not_in_england: "It looks like you have an entered a postcode outside of England. Only create logs for lettings in England."

30
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 it "has the correct check_answers_card_number" do
expect(question.check_answers_card_number).to be_nil expect(question.check_answers_card_number).to be_nil
end 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 end

Loading…
Cancel
Save