Browse Source

CLDC-1905 infer vacancy reason when renewal (#1321)

* add test for derivation of relet when renewal

* derive rsnvac when renewal set to yes, reset rsnvac when renewal set to no

* add test to ensure vacancy reasion is reset if letting is not a renewal
pull/1350/head
Arthur Campbell 2 years ago committed by GitHub
parent
commit
9fc705cc37
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 1
      app/models/derived_variables/lettings_log_variables.rb
  2. 1
      app/models/lettings_log.rb
  3. 21
      spec/models/lettings_log_spec.rb

1
app/models/derived_variables/lettings_log_variables.rb

@ -48,6 +48,7 @@ module DerivedVariables::LettingsLogVariables
self.offered = 0
self.voiddate = startdate
self.first_time_property_let_as_social_housing = 0
self.rsnvac = 14
if is_general_needs?
# fixed term
self.prevten = 32 if managing_organisation&.provider_type == "PRP"

1
app/models/lettings_log.rb

@ -518,6 +518,7 @@ private
def reset_derived_questions
dependent_questions = { waityear: [{ key: :renewal, value: 0 }],
referral: [{ key: :renewal, value: 0 }],
rsnvac: [{ key: :renewal, value: 0 }],
underoccupation_benefitcap: [{ key: :renewal, value: 0 }],
wchair: [{ key: :needstype, value: 1 }],
location_id: [{ key: :needstype, value: 1 }] }

21
spec/models/lettings_log_spec.rb

@ -1468,6 +1468,12 @@ RSpec.describe LettingsLog do
expect(record_from_db["first_time_property_let_as_social_housing"]).to eq(0)
expect(lettings_log["first_time_property_let_as_social_housing"]).to eq(0)
end
it "derives vacancy reason as relet" do
record_from_db = ActiveRecord::Base.connection.execute("select rsnvac from lettings_logs where id=#{lettings_log.id}").to_a[0]
expect(record_from_db["rsnvac"]).to eq(14)
expect(lettings_log["rsnvac"]).to eq(14)
end
end
context "when answering the household characteristics questions" do
@ -1992,6 +1998,21 @@ RSpec.describe LettingsLog do
expect(record_from_db["waityear"]).to eq(nil)
expect(lettings_log["waityear"]).to eq(nil)
end
it "resets inferred vacancy reason value" do
vacancy_reason = "rsnvac"
lettings_log.update!({ renewal: 1 })
record_from_db = ActiveRecord::Base.connection.execute("select #{vacancy_reason} from lettings_logs where id=#{lettings_log.id}").to_a[0]
expect(record_from_db[vacancy_reason]).to eq(14)
expect(lettings_log[vacancy_reason]).to eq(14)
lettings_log.update!({ renewal: 0 })
record_from_db = ActiveRecord::Base.connection.execute("select #{vacancy_reason} from lettings_logs where id=#{lettings_log.id}").to_a[0]
expect(record_from_db[vacancy_reason]).to eq(nil)
expect(lettings_log[vacancy_reason]).to eq(nil)
end
end
context "when it changes from a supported housing to not a supported housing" do

Loading…
Cancel
Save