From ac3f864ad1e67a22ce2236adab0bf1f0ff8b6cb7 Mon Sep 17 00:00:00 2001 From: kosiakkatrina <54268893+kosiakkatrina@users.noreply.github.com> Date: Tue, 27 Sep 2022 10:41:44 +0100 Subject: [PATCH] Extract voiddate out of the if statement (#903) --- app/models/derived_variables/lettings_log_variables.rb | 10 +++------- spec/features/form/check_answers_page_spec.rb | 1 + spec/features/form/validations_spec.rb | 1 + spec/models/lettings_log_spec.rb | 1 - 4 files changed, 5 insertions(+), 8 deletions(-) diff --git a/app/models/derived_variables/lettings_log_variables.rb b/app/models/derived_variables/lettings_log_variables.rb index a9cb49978..f192033f0 100644 --- a/app/models/derived_variables/lettings_log_variables.rb +++ b/app/models/derived_variables/lettings_log_variables.rb @@ -59,14 +59,10 @@ module DerivedVariables::LettingsLogVariables self.hhtype = household_type self.new_old = new_or_existing_tenant - if is_supported_housing? - if location - self.wchair = location.mobility_type_before_type_cast == "W" ? 1 : 2 - end - if is_renewal? - self.voiddate = startdate - end + if is_supported_housing? && location + self.wchair = location.mobility_type_before_type_cast == "W" ? 1 : 2 end + self.voiddate = startdate if is_renewal? self.vacdays = property_vacant_days set_housingneeds_fields if housingneeds? diff --git a/spec/features/form/check_answers_page_spec.rb b/spec/features/form/check_answers_page_spec.rb index c5080b4bc..03d237dd2 100644 --- a/spec/features/form/check_answers_page_spec.rb +++ b/spec/features/form/check_answers_page_spec.rb @@ -245,6 +245,7 @@ RSpec.describe "Form Check Answers Page" do reason: 4, ppostcode_full: "SE2 6RT", mrcdate: Time.zone.parse("03/11/2019"), + renewal: 0, ) end diff --git a/spec/features/form/validations_spec.rb b/spec/features/form/validations_spec.rb index 8defb15f6..54d4f1a48 100644 --- a/spec/features/form/validations_spec.rb +++ b/spec/features/form/validations_spec.rb @@ -10,6 +10,7 @@ RSpec.describe "validations" do :in_progress, owning_organisation: user.organisation, managing_organisation: user.organisation, + renewal: 0, ) end let(:empty_lettings_log) do diff --git a/spec/models/lettings_log_spec.rb b/spec/models/lettings_log_spec.rb index 89f51ca47..aeaff6b2a 100644 --- a/spec/models/lettings_log_spec.rb +++ b/spec/models/lettings_log_spec.rb @@ -1395,7 +1395,6 @@ RSpec.describe LettingsLog do renewal: 1, startdate: Time.zone.local(2021, 4, 10), created_at: Time.utc(2022, 2, 8, 16, 52, 15), - needstype: 2, }) end