From 1fae60c76ad00302ab5a3cccdff12089b2ab6864 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Meny?= Date: Mon, 4 Jul 2022 17:13:31 +0100 Subject: [PATCH] Rubocop fixes --- app/models/derived_variables/case_log_variables.rb | 6 ++---- spec/models/case_log_spec.rb | 6 +++--- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/app/models/derived_variables/case_log_variables.rb b/app/models/derived_variables/case_log_variables.rb index 8a80a4adf..b23b44806 100644 --- a/app/models/derived_variables/case_log_variables.rb +++ b/app/models/derived_variables/case_log_variables.rb @@ -69,10 +69,8 @@ module DerivedVariables::CaseLogVariables self.new_old = new_or_existing_tenant self.vacdays = property_vacant_days - if is_supported_housing? - if scheme && scheme.locations.size == 1 - self.location = scheme.locations.first - end + if is_supported_housing? && (scheme && scheme.locations.size == 1) + self.location = scheme.locations.first end end diff --git a/spec/models/case_log_spec.rb b/spec/models/case_log_spec.rb index bca9cbb32..23176a005 100644 --- a/spec/models/case_log_spec.rb +++ b/spec/models/case_log_spec.rb @@ -1681,9 +1681,11 @@ RSpec.describe CaseLog do context "when a case log is a supported housing log" do before { case_log.needstype = 2 } + context "and a scheme with a single log is selected" do let(:scheme) { FactoryBot.create(:scheme) } - let!(:location) { FactoryBot.create(:location, scheme:)} + let!(:location) { FactoryBot.create(:location, scheme:) } + before { case_log.update!(scheme:) } it "derives the scheme location" do @@ -2162,6 +2164,4 @@ RSpec.describe CaseLog do end end end - - end