Browse Source

look at form start date because log start date might not be given

pull/1402/head
Kat 3 years ago
parent
commit
b8dd185713
  1. 2
      app/models/lettings_log.rb
  2. 6
      spec/models/lettings_log_spec.rb

2
app/models/lettings_log.rb

@ -84,7 +84,7 @@ class LettingsLog < Log
def la def la
if location if location
location.linked_local_authorities.active(startdate).first.code location.linked_local_authorities.active(form.start_date).first.code
else else
super super
end end

6
spec/models/lettings_log_spec.rb

@ -1876,11 +1876,15 @@ RSpec.describe LettingsLog do
LocalAuthorityLink.create!(local_authority_id: LocalAuthority.find_by(code: "E07000030").id, linked_local_authority_id: LocalAuthority.find_by(code: "E06000063").id) LocalAuthorityLink.create!(local_authority_id: LocalAuthority.find_by(code: "E07000030").id, linked_local_authority_id: LocalAuthority.find_by(code: "E06000063").id)
location.update!(location_code: "E07000030") location.update!(location_code: "E07000030")
Timecop.freeze(startdate) Timecop.freeze(startdate)
Singleton.__init__(FormHandler)
lettings_log.update!(startdate:) lettings_log.update!(startdate:)
lettings_log.reload lettings_log.reload
end end
after { Timecop.unfreeze } after do
Timecop.unfreeze
Singleton.__init__(FormHandler)
end
context "with 22/23" do context "with 22/23" do
let(:startdate) { Time.zone.local(2022, 4, 2) } let(:startdate) { Time.zone.local(2022, 4, 2) }

Loading…
Cancel
Save