From bdc038b92fe0d6f315cb07d04db4ac987269b477 Mon Sep 17 00:00:00 2001 From: James Rose Date: Wed, 2 Nov 2022 12:37:36 +0000 Subject: [PATCH] Adjust referral derived value when log is a renewal Previously we inferred referral to equal `0` when renewal was `1`. This change sets `referral` to `1` when `renewal` is also `1`. --- app/models/derived_variables/lettings_log_variables.rb | 2 +- spec/models/lettings_log_spec.rb | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/models/derived_variables/lettings_log_variables.rb b/app/models/derived_variables/lettings_log_variables.rb index f192033f0..c76d5c2d9 100644 --- a/app/models/derived_variables/lettings_log_variables.rb +++ b/app/models/derived_variables/lettings_log_variables.rb @@ -45,7 +45,7 @@ module DerivedVariables::LettingsLogVariables self.nocharge = household_charge&.zero? ? 1 : 0 if is_renewal? self.underoccupation_benefitcap = 2 if collection_start_year == 2021 - self.referral = 0 + self.referral = 1 self.waityear = 2 if is_general_needs? # fixed term diff --git a/spec/models/lettings_log_spec.rb b/spec/models/lettings_log_spec.rb index dc4a646fe..f97711562 100644 --- a/spec/models/lettings_log_spec.rb +++ b/spec/models/lettings_log_spec.rb @@ -1431,8 +1431,8 @@ RSpec.describe LettingsLog do it "correctly derives and saves referral" do record_from_db = ActiveRecord::Base.connection.execute("select referral from lettings_logs where id=#{lettings_log.id}").to_a[0] - expect(record_from_db["referral"]).to eq(0) - expect(lettings_log["referral"]).to eq(0) + expect(record_from_db["referral"]).to eq(1) + expect(lettings_log["referral"]).to eq(1) end it "correctly derives and saves vacdays" do