From 0462d0ece4b8ca083493ec22832f44108bc2d602 Mon Sep 17 00:00:00 2001 From: oscar-richardson-softwire Date: Wed, 28 Jan 2026 09:33:51 +0000 Subject: [PATCH] Add test for LA override --- spec/models/lettings_log_spec.rb | 57 ++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) diff --git a/spec/models/lettings_log_spec.rb b/spec/models/lettings_log_spec.rb index 9f0ddec42..c47eaec26 100644 --- a/spec/models/lettings_log_spec.rb +++ b/spec/models/lettings_log_spec.rb @@ -590,6 +590,63 @@ RSpec.describe LettingsLog do end end + context "and the log has different LAs set on the location and the log itself" do + before do + location.update!(location_code: "E07000030") + Timecop.freeze(startdate) + Singleton.__init__(FormHandler) + lettings_log.update!(startdate:, la: "E09000002") + lettings_log.reload + end + + after do + Timecop.unfreeze + Singleton.__init__(FormHandler) + end + + context "with 25/26" do + let(:startdate) { Time.zone.local(2025, 4, 2) } + + it "returns the LA from the location" do + expect(lettings_log["location_id"]).to eq(location.id) + expect(lettings_log.la).to eq("E07000030") + end + end + + context "with 26/27" do + let(:startdate) { Time.zone.local(2026, 4, 2) } + + it "returns the LA from the log itself" do + expect(lettings_log["location_id"]).to eq(location.id) + expect(lettings_log.la).to eq("E09000002") + end + end + end + + context "and the log only has an LA set on the location" do + before do + location.update!(location_code: "E07000030") + Timecop.freeze(startdate) + Singleton.__init__(FormHandler) + lettings_log.update!(startdate:) + lettings_log.reload + end + + after do + Timecop.unfreeze + Singleton.__init__(FormHandler) + end + + context "with 26/27" do + let(:startdate) { Time.zone.local(2026, 4, 2) } + + it "returns the LA from the location" do + expect(lettings_log["location_id"]).to eq(location.id) + expect(lettings_log.la).to eq("E07000030") + end + end + end + context "and the location no local authorities associated with the location_code" do before do Timecop.freeze(Time.zone.local(2022, 4, 2))