From fc706ab6a6240097aade33828b01f7a202aa5467 Mon Sep 17 00:00:00 2001 From: baarkerlounger <5101747+baarkerlounger@users.noreply.github.com> Date: Thu, 12 May 2022 11:12:44 +0100 Subject: [PATCH] Remove needs type question until we support supported housing logs (#569) --- app/models/case_log.rb | 2 ++ config/forms/2021_2022.json | 4 +++- config/forms/2022_2023.json | 4 +++- spec/models/case_log_spec.rb | 8 +++++++- 4 files changed, 15 insertions(+), 3 deletions(-) diff --git a/app/models/case_log.rb b/app/models/case_log.rb index 5e78990f3..d168f5740 100644 --- a/app/models/case_log.rb +++ b/app/models/case_log.rb @@ -438,6 +438,8 @@ private end def set_derived_fields! + # TODO: Remove once we support supported housing logs + self.needstype = 1 unless needstype if rsnvac.present? self.newprop = has_first_let_vacancy_reason? ? 1 : 2 end diff --git a/config/forms/2021_2022.json b/config/forms/2021_2022.json index 1fe6bfb0d..422ec5dd1 100644 --- a/config/forms/2021_2022.json +++ b/config/forms/2021_2022.json @@ -27,7 +27,9 @@ } } } - } + }, + "derived": true, + "depends_on": [false] }, "renewal": { "header": "", diff --git a/config/forms/2022_2023.json b/config/forms/2022_2023.json index f445ebe7c..0adc39f8e 100644 --- a/config/forms/2022_2023.json +++ b/config/forms/2022_2023.json @@ -27,7 +27,9 @@ } } } - } + }, + "derived": true, + "depends_on": [false] }, "renewal": { "header": "", diff --git a/spec/models/case_log_spec.rb b/spec/models/case_log_spec.rb index f420ade1c..1b4c4c978 100644 --- a/spec/models/case_log_spec.rb +++ b/spec/models/case_log_spec.rb @@ -210,12 +210,17 @@ RSpec.describe CaseLog do net_income_known: 2, hhmemb: 7, rent_type: 4, - needstype: 1, hb: 1, hbrentshortfall: 1, }) end + it "derives that all forms are general needs" do + record_from_db = ActiveRecord::Base.connection.execute("select needstype from case_logs where id=#{case_log.id}").to_a[0] + expect(record_from_db["needstype"]).to eq(1) + expect(case_log["needstype"]).to eq(1) + end + it "correctly derives and saves partial and full major repairs date" do record_from_db = ActiveRecord::Base.connection.execute("select mrcdate from case_logs where id=#{case_log.id}").to_a[0] expect(record_from_db["mrcdate"].day).to eq(4) @@ -1127,6 +1132,7 @@ RSpec.describe CaseLog do expect(address_case_log[postcode_field]).to eq("M11AE") expect(record_from_db[postcode_field]).to eq("M11AE") end + context "when saving addresses" do before do stub_request(:get, /api.postcodes.io/)