Browse Source

set vacdays after setting the voiddate (#900)

pull/903/head
kosiakkatrina 2 years ago committed by GitHub
parent
commit
9bf189a919
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      app/models/derived_variables/lettings_log_variables.rb
  2. 7
      spec/models/lettings_log_spec.rb

2
app/models/derived_variables/lettings_log_variables.rb

@ -58,7 +58,6 @@ module DerivedVariables::LettingsLogVariables
self.hhtype = household_type self.hhtype = household_type
self.new_old = new_or_existing_tenant self.new_old = new_or_existing_tenant
self.vacdays = property_vacant_days
if is_supported_housing? if is_supported_housing?
if location if location
@ -68,6 +67,7 @@ module DerivedVariables::LettingsLogVariables
self.voiddate = startdate self.voiddate = startdate
end end
end end
self.vacdays = property_vacant_days
set_housingneeds_fields if housingneeds? set_housingneeds_fields if housingneeds?
end end

7
spec/models/lettings_log_spec.rb

@ -1395,6 +1395,7 @@ RSpec.describe LettingsLog do
renewal: 1, renewal: 1,
startdate: Time.zone.local(2021, 4, 10), startdate: Time.zone.local(2021, 4, 10),
created_at: Time.utc(2022, 2, 8, 16, 52, 15), created_at: Time.utc(2022, 2, 8, 16, 52, 15),
needstype: 2,
}) })
end end
@ -1431,6 +1432,12 @@ RSpec.describe LettingsLog do
expect(record_from_db["referral"]).to eq(0) expect(record_from_db["referral"]).to eq(0)
expect(lettings_log["referral"]).to eq(0) expect(lettings_log["referral"]).to eq(0)
end end
it "correctly derives and saves vacdays" do
record_from_db = ActiveRecord::Base.connection.execute("select vacdays from lettings_logs where id=#{lettings_log.id}").to_a[0]
expect(record_from_db["vacdays"]).to eq(0)
expect(lettings_log["vacdays"]).to eq(0)
end
end end
context "when answering the household characteristics questions" do context "when answering the household characteristics questions" do

Loading…
Cancel
Save