From 409c087271cc2ec32f8afb443a8706b0df94e4e2 Mon Sep 17 00:00:00 2001 From: samyou-softwire Date: Tue, 24 Mar 2026 15:15:56 +0000 Subject: [PATCH] CLDC-4340: Add a verifying test --- .../form/lettings/questions/location_id_spec.rb | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/spec/models/form/lettings/questions/location_id_spec.rb b/spec/models/form/lettings/questions/location_id_spec.rb index 2ea72c705..ea2e68100 100644 --- a/spec/models/form/lettings/questions/location_id_spec.rb +++ b/spec/models/form/lettings/questions/location_id_spec.rb @@ -166,6 +166,19 @@ RSpec.describe Form::Lettings::Questions::LocationId, type: :model do ]) end end + + context "and some locations don't have names" do + before do + FactoryBot.create(:location, scheme:, startdate: Time.utc(2022, 5, 7), name: "other name", postcode: "AA1 1AA") + FactoryBot.create(:location, scheme:, startdate: Time.utc(2022, 5, 6), name: nil, postcode: "AA1 1AB") + FactoryBot.create(:location, scheme:, startdate: Time.utc(2022, 5, 5), name: "A", postcode: "AA1 1AC") + lettings_log.update!(scheme:) + end + + it "uses the postcode as a fallback" do + expect(question.displayed_answer_options(lettings_log).values.map { |v| v["value"] }).to eq(["AA1 1AC", "AA1 1AB", "AA1 1AA"]) + end + end end end