From 41984e01ec8c20e16d6a7e5c28a05dc9da399bce Mon Sep 17 00:00:00 2001 From: kosiakkatrina <54268893+kosiakkatrina@users.noreply.github.com> Date: Tue, 23 Aug 2022 16:42:01 +0100 Subject: [PATCH 1/2] Cldc 1434 csv column ordering (#842) * order csv attributes based on the form * Move is inferred csv attributes next to the inferred fields * Add is dpo, move scheme fields to back * move checkbox answer options * extract move_csv_attributes method * choose year based on which case logs are downloaded * typo * Extract case log csv class * Move csv class to services * update schema --- app/models/case_log.rb | 26 +----- app/services/csv/case_log_csv_service.rb | 90 +++++++++++++++++++ db/schema.rb | 2 + spec/fixtures/files/case_logs_download.csv | 4 +- .../files/case_logs_download_non_support.csv | 4 +- spec/requests/case_logs_controller_spec.rb | 2 +- 6 files changed, 101 insertions(+), 27 deletions(-) create mode 100644 app/services/csv/case_log_csv_service.rb diff --git a/app/models/case_log.rb b/app/models/case_log.rb index 4f4e535a3..3f61ed4e4 100644 --- a/app/models/case_log.rb +++ b/app/models/case_log.rb @@ -74,7 +74,6 @@ class CaseLog < ApplicationRecord NUM_OF_WEEKS_FROM_PERIOD = { 2 => 26, 3 => 13, 4 => 12, 5 => 50, 6 => 49, 7 => 48, 8 => 47, 9 => 46, 1 => 52 }.freeze SUFFIX_FROM_PERIOD = { 2 => "every 2 weeks", 3 => "every 4 weeks", 4 => "every month" }.freeze RETIREMENT_AGES = { "M" => 67, "F" => 60, "X" => 67 }.freeze - CSV_FIELDS_TO_OMIT = %w[hhmemb net_income_value_check sale_or_letting first_time_property_let_as_social_housing renttype needstype postcode_known is_la_inferred totchild totelder totadult net_income_known is_carehome previous_la_known is_previous_la_inferred age1_known age2_known age3_known age4_known age5_known age6_known age7_known age8_known letting_allocation_unknown details_known_2 details_known_3 details_known_4 details_known_5 details_known_6 details_known_7 details_known_8 rent_type wrent wscharge wpschrge wsupchrg wtcharge wtshortfall rent_value_check old_form_id old_id retirement_value_check tshortfall_known pregnancy_value_check hhtype new_old vacdays].freeze enum status: STATUS def form @@ -439,29 +438,12 @@ class CaseLog < ApplicationRecord created_by&.name end - def self.to_csv(user = nil) - CSV.generate(headers: true) do |csv| - attributes = csv_attributes(user) - csv << attributes - - all.find_each do |record| - csv << attributes.map do |att| - record.form.get_question(att, record)&.label_from_value(record.send(att)) || label_from_value(record.send(att)) - end - end - end + def is_dpo + created_by&.is_dpo end - def self.label_from_value(value) - return "Yes" if value == true - return "No" if value == false - - value - end - - def self.csv_attributes(user) - attributes = attribute_names - %w[owning_organisation_id managing_organisation_id created_by_id] + %w[unittype_sh owning_organisation_name managing_organisation_name created_by_name] - user.present? && !user.support? ? attributes - CSV_FIELDS_TO_OMIT : attributes + def self.to_csv(user = nil) + Csv::CaseLogCsvService.new(user).to_csv end def soft_min_for_period diff --git a/app/services/csv/case_log_csv_service.rb b/app/services/csv/case_log_csv_service.rb new file mode 100644 index 000000000..f092ba5b5 --- /dev/null +++ b/app/services/csv/case_log_csv_service.rb @@ -0,0 +1,90 @@ +module Csv + class CaseLogCsvService + CSV_FIELDS_TO_OMIT = %w[hhmemb net_income_value_check sale_or_letting first_time_property_let_as_social_housing renttype needstype postcode_known is_la_inferred totchild totelder totadult net_income_known is_carehome previous_la_known is_previous_la_inferred age1_known age2_known age3_known age4_known age5_known age6_known age7_known age8_known letting_allocation_unknown details_known_2 details_known_3 details_known_4 details_known_5 details_known_6 details_known_7 details_known_8 rent_type wrent wscharge wpschrge wsupchrg wtcharge wtshortfall rent_value_check old_form_id old_id retirement_value_check tshortfall_known pregnancy_value_check hhtype new_old vacdays].freeze + + def initialize(user) + @user = user + set_csv_attributes + end + + def to_csv + CSV.generate(headers: true) do |csv| + csv << @attributes + + CaseLog.all.find_each do |record| + csv << @attributes.map do |att| + record.form.get_question(att, record)&.label_from_value(record.send(att)) || label_from_value(record.send(att)) + end + end + end + end + + private + + def label_from_value(value) + return "Yes" if value == true + return "No" if value == false + + value + end + + def set_csv_attributes + @attributes = CaseLog.attribute_names + %w[unittype_sh] + replace_csv_id_fields_with_names + order_csv_attributes + + @attributes -= CSV_FIELDS_TO_OMIT if @user.present? && !@user.support? + end + + def replace_csv_id_fields_with_names + { "managing_organisation_id": "managing_organisation_name", "owning_organisation_id": "owning_organisation_name", "created_by_id": "created_by_name" }.each { |current, new_attribute| @attributes[@attributes.index(current.to_s)] = new_attribute } + end + + def order_csv_attributes + downloaded_form_years = CaseLog.all.map(&:collection_start_year).uniq.compact + + downloaded_form_fields = downloaded_form_years.count == 1 && downloaded_form_years[0].present? ? FormHandler.instance.get_form("#{downloaded_form_years[0]}_#{downloaded_form_years[0] + 1}").questions : FormHandler.instance.forms.first.second.questions + ordered_default_form_questions = move_checkbox_answer_options(downloaded_form_fields) + + @attributes = (ordered_default_form_questions & @attributes) + (@attributes - ordered_default_form_questions) + move_metadata_fields_to_front + move_is_inferred_fields + move_scheme_fields_to_back + end + + def move_checkbox_answer_options(form_questions) + checkboxes = form_questions.filter { |question| question.type == "checkbox" }.map { |question| { "#{question.id}": question.answer_options.keys } } + attributes = form_questions.map(&:id).uniq + + checkboxes.each do |checkbox_question| + checkbox_question.values[0].each do |answer_option| + attributes.insert(attributes.find_index(checkbox_question.keys[0].to_s), answer_option) + end + end + attributes + end + + def move_metadata_fields_to_front + metadata_fields = %w[managing_organisation_name owning_organisation_name is_dpo created_by_name updated_at created_at status id] + move_csv_attributes(metadata_fields, 0) + end + + def move_is_inferred_fields + { is_la_inferred: "la", is_previous_la_inferred: "prevloc" }.each do |field, inferred_field| + @attributes.delete(field.to_s) + @attributes.insert(@attributes.find_index(inferred_field), field.to_s) + end + end + + def move_scheme_fields_to_back + move_csv_attributes(%w[scheme_id location_id], -1) + end + + def move_csv_attributes(fields_to_move, index) + fields_to_move.each do |field| + @attributes.delete(field) + @attributes.insert(index, field) + end + end + end +end diff --git a/db/schema.rb b/db/schema.rb index 206fc69b0..ebb6822aa 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -202,6 +202,8 @@ ActiveRecord::Schema[7.0].define(version: 2022_08_10_152340) do t.bigint "location_id" t.integer "major_repairs_date_value_check" t.integer "void_date_value_check" + t.integer "housingneeds_type" + t.integer "housingneeds_other" t.index ["created_by_id"], name: "index_case_logs_on_created_by_id" t.index ["location_id"], name: "index_case_logs_on_location_id" t.index ["managing_organisation_id"], name: "index_case_logs_on_managing_organisation_id" diff --git a/spec/fixtures/files/case_logs_download.csv b/spec/fixtures/files/case_logs_download.csv index b1d71dfec..62f6e4b64 100644 --- a/spec/fixtures/files/case_logs_download.csv +++ b/spec/fixtures/files/case_logs_download.csv @@ -1,2 +1,2 @@ -id,status,created_at,updated_at,tenancycode,age1,sex1,ethnic,national,prevten,ecstat1,hhmemb,age2,sex2,ecstat2,age3,sex3,ecstat3,age4,sex4,ecstat4,age5,sex5,ecstat5,age6,sex6,ecstat6,age7,sex7,ecstat7,age8,sex8,ecstat8,homeless,underoccupation_benefitcap,leftreg,reservist,illness,preg_occ,startertenancy,tenancylength,tenancy,ppostcode_full,rsnvac,unittype_gn,beds,offered,wchair,earnings,incfreq,benefits,period,layear,waityear,postcode_full,reasonpref,cbl,chr,cap,reasonother,housingneeds_a,housingneeds_b,housingneeds_c,housingneeds_f,housingneeds_g,housingneeds_h,illness_type_1,illness_type_2,illness_type_3,illness_type_4,illness_type_8,illness_type_5,illness_type_6,illness_type_7,illness_type_9,illness_type_10,rp_homeless,rp_insan_unsat,rp_medwel,rp_hardship,rp_dontknow,tenancyother,net_income_value_check,property_owner_organisation,property_manager_organisation,sale_or_letting,irproduct_other,purchaser_code,reason,propcode,majorrepairs,la,prevloc,hb,hbrentshortfall,property_relet,mrcdate,incref,sale_completion_date,startdate,armedforces,first_time_property_let_as_social_housing,unitletas,builtype,voiddate,renttype,needstype,lettype,postcode_known,is_la_inferred,totchild,totelder,totadult,net_income_known,nocharge,is_carehome,household_charge,referral,brent,scharge,pscharge,supcharg,tcharge,tshortfall,chcharge,declaration,ppcodenk,previous_la_known,is_previous_la_inferred,age1_known,age2_known,age3_known,age4_known,age5_known,age6_known,age7_known,age8_known,ethnic_group,ethnic_other,letting_allocation_unknown,details_known_2,details_known_3,details_known_4,details_known_5,details_known_6,details_known_7,details_known_8,rent_type,has_benefits,renewal,wrent,wscharge,wpschrge,wsupchrg,wtcharge,wtshortfall,refused,housingneeds,wchchrg,newprop,relat2,relat3,relat4,relat5,relat6,relat7,relat8,rent_value_check,old_form_id,lar,irproduct,old_id,joint,illness_type_0,retirement_value_check,tshortfall_known,sheltered,pregnancy_value_check,hhtype,new_old,vacdays,scheme_id,location_id,major_repairs_date_value_check,void_date_value_check,unittype_sh,owning_organisation_name,managing_organisation_name,created_by_name -{id},in_progress,2022-02-08 16:52:15 +0000,2022-02-08 16:52:15 +0000,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,2,,,,,,,SE1 1TE,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,Westminster,,,,,,,,,,,,,,,Supported housing,,,No,0,0,0,,0,,,,,,,,,,,,,,No,,,,,,,,,,,,,,,,,,,,0,,,,,,,,0,,,,,,,,,,,,,,,,,,,,,,9,,,{scheme_id},SE1 1TE,,,6,DLUHC,DLUHC,Danny Rojas +id,status,created_at,updated_at,created_by_name,is_dpo,owning_organisation_name,managing_organisation_name,needstype,renewal,startdate,rent_type,irproduct_other,tenancycode,propcode,age1,sex1,ecstat1,hhmemb,relat2,age2,sex2,retirement_value_check,ecstat2,armedforces,leftreg,illness,housingneeds_a,housingneeds_b,housingneeds_c,housingneeds_h,is_previous_la_inferred,prevloc,illness_type_1,illness_type_2,is_la_inferred,la,postcode_known,postcode_full,previous_la_known,wchair,preg_occ,cbl,earnings,incfreq,net_income_value_check,benefits,hb,period,brent,scharge,pscharge,supcharg,tcharge,offered,layear,ppostcode_full,mrcdate,declaration,ethnic,national,prevten,age3,sex3,ecstat3,age4,sex4,ecstat4,age5,sex5,ecstat5,age6,sex6,ecstat6,age7,sex7,ecstat7,age8,sex8,ecstat8,homeless,underoccupation_benefitcap,reservist,startertenancy,tenancylength,tenancy,rsnvac,unittype_gn,beds,waityear,reasonpref,chr,cap,reasonother,housingneeds_f,housingneeds_g,illness_type_3,illness_type_4,illness_type_8,illness_type_5,illness_type_6,illness_type_7,illness_type_9,illness_type_10,rp_homeless,rp_insan_unsat,rp_medwel,rp_hardship,rp_dontknow,tenancyother,property_owner_organisation,property_manager_organisation,sale_or_letting,purchaser_code,reason,majorrepairs,hbrentshortfall,property_relet,incref,sale_completion_date,first_time_property_let_as_social_housing,unitletas,builtype,voiddate,renttype,lettype,totchild,totelder,totadult,net_income_known,nocharge,is_carehome,household_charge,referral,tshortfall,chcharge,ppcodenk,age1_known,age2_known,age3_known,age4_known,age5_known,age6_known,age7_known,age8_known,ethnic_group,ethnic_other,letting_allocation_unknown,details_known_2,details_known_3,details_known_4,details_known_5,details_known_6,details_known_7,details_known_8,has_benefits,wrent,wscharge,wpschrge,wsupchrg,wtcharge,wtshortfall,refused,housingneeds,wchchrg,newprop,relat3,relat4,relat5,relat6,relat7,relat8,rent_value_check,old_form_id,lar,irproduct,old_id,joint,illness_type_0,tshortfall_known,sheltered,pregnancy_value_check,hhtype,new_old,vacdays,major_repairs_date_value_check,void_date_value_check,housingneeds_type,housingneeds_other,unittype_sh,scheme_id,location_id +{id},in_progress,2022-02-08 16:52:15 +0000,2022-02-08 16:52:15 +0000,Danny Rojas,No,DLUHC,DLUHC,Supported housing,,,,,,,,,,,,,,,,,,,,,,,No,,,,No,Westminster,,SE1 1TE,,2,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,0,0,0,,0,,,,,,,,,,,,,,,,,,,,,,,,,0,,,,,,,0,,,,,,,,,,,,,,,,,,,,9,,,,,,,6,{scheme_id},SE1 1TE diff --git a/spec/fixtures/files/case_logs_download_non_support.csv b/spec/fixtures/files/case_logs_download_non_support.csv index 0c24699c0..a2b12c89b 100644 --- a/spec/fixtures/files/case_logs_download_non_support.csv +++ b/spec/fixtures/files/case_logs_download_non_support.csv @@ -1,2 +1,2 @@ -id,status,created_at,updated_at,tenancycode,age1,sex1,ethnic,national,prevten,ecstat1,age2,sex2,ecstat2,age3,sex3,ecstat3,age4,sex4,ecstat4,age5,sex5,ecstat5,age6,sex6,ecstat6,age7,sex7,ecstat7,age8,sex8,ecstat8,homeless,underoccupation_benefitcap,leftreg,reservist,illness,preg_occ,startertenancy,tenancylength,tenancy,ppostcode_full,rsnvac,unittype_gn,beds,offered,wchair,earnings,incfreq,benefits,period,layear,waityear,postcode_full,reasonpref,cbl,chr,cap,reasonother,housingneeds_a,housingneeds_b,housingneeds_c,housingneeds_f,housingneeds_g,housingneeds_h,illness_type_1,illness_type_2,illness_type_3,illness_type_4,illness_type_8,illness_type_5,illness_type_6,illness_type_7,illness_type_9,illness_type_10,rp_homeless,rp_insan_unsat,rp_medwel,rp_hardship,rp_dontknow,tenancyother,property_owner_organisation,property_manager_organisation,irproduct_other,purchaser_code,reason,propcode,majorrepairs,la,prevloc,hb,hbrentshortfall,property_relet,mrcdate,incref,sale_completion_date,startdate,armedforces,unitletas,builtype,voiddate,lettype,nocharge,household_charge,referral,brent,scharge,pscharge,supcharg,tcharge,tshortfall,chcharge,declaration,ppcodenk,ethnic_group,ethnic_other,has_benefits,renewal,refused,housingneeds,wchchrg,newprop,relat2,relat3,relat4,relat5,relat6,relat7,relat8,lar,irproduct,joint,illness_type_0,sheltered,scheme_id,location_id,major_repairs_date_value_check,void_date_value_check,unittype_sh,owning_organisation_name,managing_organisation_name,created_by_name -{id},in_progress,2022-02-08 16:52:15 +0000,2022-02-08 16:52:15 +0000,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,2,,,,,,,SE1 1TE,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,Westminster,,,,,,,,,,,,,,0,,,,,,,,,,,,,,0,,0,,,,,,,,,,,,,,,,{scheme_id},SE1 1TE,,,6,DLUHC,DLUHC,Danny Rojas +id,status,created_at,updated_at,created_by_name,is_dpo,owning_organisation_name,managing_organisation_name,renewal,startdate,irproduct_other,tenancycode,propcode,age1,sex1,ecstat1,relat2,age2,sex2,ecstat2,armedforces,leftreg,illness,housingneeds_a,housingneeds_b,housingneeds_c,housingneeds_h,prevloc,illness_type_1,illness_type_2,la,postcode_full,wchair,preg_occ,cbl,earnings,incfreq,benefits,hb,period,brent,scharge,pscharge,supcharg,tcharge,offered,layear,ppostcode_full,mrcdate,declaration,ethnic,national,prevten,age3,sex3,ecstat3,age4,sex4,ecstat4,age5,sex5,ecstat5,age6,sex6,ecstat6,age7,sex7,ecstat7,age8,sex8,ecstat8,homeless,underoccupation_benefitcap,reservist,startertenancy,tenancylength,tenancy,rsnvac,unittype_gn,beds,waityear,reasonpref,chr,cap,reasonother,housingneeds_f,housingneeds_g,illness_type_3,illness_type_4,illness_type_8,illness_type_5,illness_type_6,illness_type_7,illness_type_9,illness_type_10,rp_homeless,rp_insan_unsat,rp_medwel,rp_hardship,rp_dontknow,tenancyother,property_owner_organisation,property_manager_organisation,purchaser_code,reason,majorrepairs,hbrentshortfall,property_relet,incref,sale_completion_date,unitletas,builtype,voiddate,lettype,nocharge,household_charge,referral,tshortfall,chcharge,ppcodenk,ethnic_group,ethnic_other,has_benefits,refused,housingneeds,wchchrg,newprop,relat3,relat4,relat5,relat6,relat7,relat8,lar,irproduct,joint,illness_type_0,sheltered,major_repairs_date_value_check,void_date_value_check,housingneeds_type,housingneeds_other,unittype_sh,scheme_id,location_id +{id},in_progress,2022-02-08 16:52:15 +0000,2022-02-08 16:52:15 +0000,Danny Rojas,No,DLUHC,DLUHC,,,,,,,,,,,,,,,,,,,,,,,Westminster,SE1 1TE,2,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,0,,,,,,,,0,0,,,,,,,,,,,,,,,,,,,6,{scheme_id},SE1 1TE diff --git a/spec/requests/case_logs_controller_spec.rb b/spec/requests/case_logs_controller_spec.rb index 5c4ce4dca..6ed0854ed 100644 --- a/spec/requests/case_logs_controller_spec.rb +++ b/spec/requests/case_logs_controller_spec.rb @@ -766,7 +766,7 @@ RSpec.describe CaseLogsController, type: :request do it "downloads answer labels rather than values" do csv = CSV.parse(response.body) - expect(csv.second[10]).to eq("Full-time – 30 hours or more") + expect(csv.second[15]).to eq("Full-time – 30 hours or more") end it "downloads filtered logs" do From 6ff7db39f1d2262bdb0b0309f517cacc9c9c41a7 Mon Sep 17 00:00:00 2001 From: baarkerlounger <5101747+baarkerlounger@users.noreply.github.com> Date: Wed, 24 Aug 2022 09:49:13 +0100 Subject: [PATCH 2/2] Remove schemes feature flag (#841) --- app/components/primary_navigation_component.rb | 1 - app/models/derived_variables/case_log_variables.rb | 6 ------ app/models/form/setup/pages/location.rb | 1 - app/models/form/setup/pages/needs_type.rb | 1 - app/models/form/setup/pages/rent_type.rb | 1 - app/models/form/setup/pages/scheme.rb | 1 - app/models/form/setup/questions/needs_type.rb | 1 - app/models/form/setup/questions/scheme_id.rb | 1 - config/initializers/feature_toggle.rb | 4 ---- spec/models/case_log_spec.rb | 7 ------- spec/models/form/setup/pages/location_spec.rb | 1 - spec/models/form/setup/pages/needs_type_spec.rb | 4 ---- spec/models/form/setup/pages/rent_type_spec.rb | 4 ---- spec/models/form/setup/pages/scheme_spec.rb | 4 ---- 14 files changed, 37 deletions(-) diff --git a/app/components/primary_navigation_component.rb b/app/components/primary_navigation_component.rb index 82a12e447..0389d30b3 100644 --- a/app/components/primary_navigation_component.rb +++ b/app/components/primary_navigation_component.rb @@ -3,7 +3,6 @@ class PrimaryNavigationComponent < ViewComponent::Base def initialize(items:) @items = items - FeatureToggle.supported_housing_schemes_enabled? ? @items : @items.reject! { |nav_item| nav_item.text.include?("Schemes") } super end diff --git a/app/models/derived_variables/case_log_variables.rb b/app/models/derived_variables/case_log_variables.rb index ea4df8009..3bf227b6f 100644 --- a/app/models/derived_variables/case_log_variables.rb +++ b/app/models/derived_variables/case_log_variables.rb @@ -1,10 +1,6 @@ module DerivedVariables::CaseLogVariables RENT_TYPE_MAPPING = { 0 => 1, 1 => 2, 2 => 2, 3 => 3, 4 => 3, 5 => 3 }.freeze - def supported_housing_schemes_enabled? - FeatureToggle.supported_housing_schemes_enabled? - end - def scheme_has_multiple_locations? return false unless scheme @@ -15,8 +11,6 @@ module DerivedVariables::CaseLogVariables def set_derived_fields! # TODO: Remove once we support parent/child relationships self.managing_organisation_id ||= owning_organisation_id - # TODO: Remove once we support supported housing logs - self.needstype = 1 unless supported_housing_schemes_enabled? if rsnvac.present? self.newprop = has_first_let_vacancy_reason? ? 1 : 2 end diff --git a/app/models/form/setup/pages/location.rb b/app/models/form/setup/pages/location.rb index 4a86c9a9a..7acbc1bbe 100644 --- a/app/models/form/setup/pages/location.rb +++ b/app/models/form/setup/pages/location.rb @@ -4,7 +4,6 @@ class Form::Setup::Pages::Location < ::Form::Page @header = "" @description = "" @depends_on = [{ - "supported_housing_schemes_enabled?" => true, "needstype" => 2, "scheme_has_multiple_locations?" => true, }] diff --git a/app/models/form/setup/pages/needs_type.rb b/app/models/form/setup/pages/needs_type.rb index 0db6ef1c2..2625d6cda 100644 --- a/app/models/form/setup/pages/needs_type.rb +++ b/app/models/form/setup/pages/needs_type.rb @@ -4,7 +4,6 @@ class Form::Setup::Pages::NeedsType < ::Form::Page @id = "needs_type" @header = "" @description = "" - @depends_on = [{ "supported_housing_schemes_enabled?" => true }] @subsection = subsection end diff --git a/app/models/form/setup/pages/rent_type.rb b/app/models/form/setup/pages/rent_type.rb index 9c927c9af..5e112c3c6 100644 --- a/app/models/form/setup/pages/rent_type.rb +++ b/app/models/form/setup/pages/rent_type.rb @@ -3,7 +3,6 @@ class Form::Setup::Pages::RentType < ::Form::Page super("rent_type", hsh, subsection) @header = "" @description = "" - @depends_on = [{ "supported_housing_schemes_enabled?" => true }] @derived = true end diff --git a/app/models/form/setup/pages/scheme.rb b/app/models/form/setup/pages/scheme.rb index 2b9cc5dbf..e71a8d424 100644 --- a/app/models/form/setup/pages/scheme.rb +++ b/app/models/form/setup/pages/scheme.rb @@ -4,7 +4,6 @@ class Form::Setup::Pages::Scheme < ::Form::Page @header = "" @description = "" @depends_on = [{ - "supported_housing_schemes_enabled?" => true, "needstype" => 2, }] end diff --git a/app/models/form/setup/questions/needs_type.rb b/app/models/form/setup/questions/needs_type.rb index 4222cbb37..01c52b8cc 100644 --- a/app/models/form/setup/questions/needs_type.rb +++ b/app/models/form/setup/questions/needs_type.rb @@ -7,7 +7,6 @@ class Form::Setup::Questions::NeedsType < ::Form::Question @hint_text = "General needs housing includes both self-contained and shared housing without support or specific adaptations. Supported housing can include direct access hostels, group homes, residential care and nursing homes." @type = "radio" @answer_options = ANSWER_OPTIONS - @derived = true unless FeatureToggle.supported_housing_schemes_enabled? @page = page end diff --git a/app/models/form/setup/questions/scheme_id.rb b/app/models/form/setup/questions/scheme_id.rb index 3c4985de1..4686878da 100644 --- a/app/models/form/setup/questions/scheme_id.rb +++ b/app/models/form/setup/questions/scheme_id.rb @@ -6,7 +6,6 @@ class Form::Setup::Questions::SchemeId < ::Form::Question @hint_text = "Enter scheme name or postcode" @type = "select" @answer_options = answer_options - @derived = true unless FeatureToggle.supported_housing_schemes_enabled? @guidance_position = GuidancePosition::BOTTOM @guidance_partial = "scheme_selection" end diff --git a/config/initializers/feature_toggle.rb b/config/initializers/feature_toggle.rb index ffb6c6623..50501fb65 100644 --- a/config/initializers/feature_toggle.rb +++ b/config/initializers/feature_toggle.rb @@ -1,8 +1,4 @@ class FeatureToggle - def self.supported_housing_schemes_enabled? - true - end - def self.startdate_two_week_validation_enabled? true end diff --git a/spec/models/case_log_spec.rb b/spec/models/case_log_spec.rb index fbf7643ee..cbe1666cf 100644 --- a/spec/models/case_log_spec.rb +++ b/spec/models/case_log_spec.rb @@ -2285,13 +2285,6 @@ RSpec.describe CaseLog do end end - describe "supported_housing_schemes_enabled?" do - it "returns true for the case log if the environment is not production" do - case_log = FactoryBot.create(:case_log) - expect(case_log.supported_housing_schemes_enabled?).to eq(true) - end - end - describe "csv download" do let(:scheme) { FactoryBot.create(:scheme) } let(:location) { FactoryBot.create(:location, :export, scheme:, type_of_unit: 6, postcode: "SE11TE") } diff --git a/spec/models/form/setup/pages/location_spec.rb b/spec/models/form/setup/pages/location_spec.rb index b3c1d06a9..10db3d331 100644 --- a/spec/models/form/setup/pages/location_spec.rb +++ b/spec/models/form/setup/pages/location_spec.rb @@ -29,7 +29,6 @@ RSpec.describe Form::Setup::Pages::Location, type: :model do it "has the correct depends_on" do expect(page.depends_on).to eq([{ - "supported_housing_schemes_enabled?" => true, "needstype" => 2, "scheme_has_multiple_locations?" => true, }]) diff --git a/spec/models/form/setup/pages/needs_type_spec.rb b/spec/models/form/setup/pages/needs_type_spec.rb index 88b10fd64..772c2a11d 100644 --- a/spec/models/form/setup/pages/needs_type_spec.rb +++ b/spec/models/form/setup/pages/needs_type_spec.rb @@ -26,8 +26,4 @@ RSpec.describe Form::Setup::Pages::NeedsType, type: :model do it "has the correct description" do expect(page.description).to eq("") end - - it "has the correct depends_on" do - expect(page.depends_on).to eq([{ "supported_housing_schemes_enabled?" => true }]) - end end diff --git a/spec/models/form/setup/pages/rent_type_spec.rb b/spec/models/form/setup/pages/rent_type_spec.rb index 981ca4bf6..d558ea75c 100644 --- a/spec/models/form/setup/pages/rent_type_spec.rb +++ b/spec/models/form/setup/pages/rent_type_spec.rb @@ -26,8 +26,4 @@ RSpec.describe Form::Setup::Pages::RentType, type: :model do it "has the correct description" do expect(page.description).to eq("") end - - it "has the correct depends_on" do - expect(page.depends_on).to eq([{ "supported_housing_schemes_enabled?" => true }]) - end end diff --git a/spec/models/form/setup/pages/scheme_spec.rb b/spec/models/form/setup/pages/scheme_spec.rb index 841516fe5..7c3566009 100644 --- a/spec/models/form/setup/pages/scheme_spec.rb +++ b/spec/models/form/setup/pages/scheme_spec.rb @@ -26,8 +26,4 @@ RSpec.describe Form::Setup::Pages::Scheme, type: :model do it "has the correct description" do expect(page.description).to eq("") end - - it "has the correct depends_on" do - expect(page.depends_on).to eq([{ "needstype" => 2, "supported_housing_schemes_enabled?" => true }]) - end end