From 6d2a0a11b697d6c49b420c8fd1a5b7eac0a4c6c1 Mon Sep 17 00:00:00 2001 From: magicmilo Date: Thu, 11 Nov 2021 19:44:57 +0000 Subject: [PATCH] Revert "Merge branch 'main' of https://github.com/communitiesuk/mhclg-data-collection-beta" This reverts commit d1ae40dc3bd4a03c6805e7c2462b1d6c706dfed6, reversing changes made to 3f885b4bc3101519784e0b0777a0c78207db8e54. --- app/admin/case_logs.rb | 2 +- app/models/case_log.rb | 8 +------- app/validations/household_validations.rb | 2 +- config/forms/2021_2022.json | 16 ++++++++++++++-- .../20211111143319_add_other_members_column.rb | 7 ------- db/schema.rb | 3 +-- docs/api/DLUHC-CORE-Data.v1.json | 6 +++--- spec/features/case_log_spec.rb | 4 ++-- spec/fixtures/complete_case_log.json | 3 +-- spec/fixtures/forms/test_form.json | 2 +- spec/helpers/check_answers_helper_spec.rb | 2 +- spec/models/case_log_spec.rb | 4 ++-- 12 files changed, 28 insertions(+), 31 deletions(-) delete mode 100644 db/migrate/20211111143319_add_other_members_column.rb diff --git a/app/admin/case_logs.rb b/app/admin/case_logs.rb index 2a15fbb2a..f32cff52b 100644 --- a/app/admin/case_logs.rb +++ b/app/admin/case_logs.rb @@ -2,7 +2,7 @@ ActiveAdmin.register CaseLog do # See permitted parameters documentation: # https://github.com/activeadmin/activeadmin/blob/master/docs/2-resource-customization.md#setting-up-strong-parameters permit_params do - permitted = %i[status tenant_code age1 sex1 tenant_ethnic_group tenant_nationality previous_housing_situation armed_forces ecstat1 other_hhmemb relat2 age2 sex2 ecstat2 relat3 age3 sex3 ecstat3 relat4 age4 sex4 ecstat4 relat5 age5 sex5 ecstat5 relat6 age6 sex6 ecstat6 relat7 age7 person_7_gender ecstat7 relat8 age8 sex8 ecstat8 homelessness reason benefit_cap_spare_room_subsidy armed_forces_active armed_forces_injured armed_forces_partner medical_conditions pregnancy accessibility_requirements condition_effects tenancy_code tenancy_start_date starter_tenancy fixed_term_tenancy tenancy_type letting_type letting_provider la previous_postcode property_relet property_vacancy_reason property_reference property_unit_type property_building_type property_number_of_bedrooms property_void_date majorrepairs mrcdate property_number_of_times_relet property_wheelchair_accessible net_income net_income_frequency net_income_uc_proportion hb rent_frequency basic_rent service_charge personal_service_charge support_charge total_charge tshortfall time_lived_in_la time_on_la_waiting_list prevloc property_postcode reasonable_preference reasonable_preference_reason cbl_letting chr_letting cap_letting hbrentshortfall other_reason accessibility_requirements_fully_wheelchair_accessible_housing accessibility_requirements_wheelchair_access_to_essential_rooms accessibility_requirements_level_access_housing accessibility_requirements_other_disability_requirements accessibility_requirements_no_disability_requirements accessibility_requirements_do_not_know accessibility_requirements_prefer_not_to_say condition_effects_vision condition_effects_hearing condition_effects_mobility condition_effects_dexterity condition_effects_stamina condition_effects_learning condition_effects_memory condition_effects_mental_health condition_effects_social_or_behavioral condition_effects_other condition_effects_prefer_not_to_say reasonable_preference_reason_homeless reasonable_preference_reason_unsatisfactory_housing reasonable_preference_reason_medical_grounds reasonable_preference_reason_avoid_hardship reasonable_preference_reason_do_not_know other_tenancy_type override_net_income_validation net_income_known] + permitted = %i[status tenant_code age1 sex1 tenant_ethnic_group tenant_nationality previous_housing_situation armed_forces ecstat1 hhmemb relat2 age2 sex2 ecstat2 relat3 age3 sex3 ecstat3 relat4 age4 sex4 ecstat4 relat5 age5 sex5 ecstat5 relat6 age6 sex6 ecstat6 relat7 age7 person_7_gender ecstat7 relat8 age8 sex8 ecstat8 homelessness reason benefit_cap_spare_room_subsidy armed_forces_active armed_forces_injured armed_forces_partner medical_conditions pregnancy accessibility_requirements condition_effects tenancy_code tenancy_start_date starter_tenancy fixed_term_tenancy tenancy_type letting_type letting_provider la previous_postcode property_relet property_vacancy_reason property_reference property_unit_type property_building_type property_number_of_bedrooms property_void_date majorrepairs mrcdate property_number_of_times_relet property_wheelchair_accessible net_income net_income_frequency net_income_uc_proportion hb rent_frequency basic_rent service_charge personal_service_charge support_charge total_charge tshortfall time_lived_in_la time_on_la_waiting_list prevloc property_postcode reasonable_preference reasonable_preference_reason cbl_letting chr_letting cap_letting hbrentshortfall other_reason accessibility_requirements_fully_wheelchair_accessible_housing accessibility_requirements_wheelchair_access_to_essential_rooms accessibility_requirements_level_access_housing accessibility_requirements_other_disability_requirements accessibility_requirements_no_disability_requirements accessibility_requirements_do_not_know accessibility_requirements_prefer_not_to_say condition_effects_vision condition_effects_hearing condition_effects_mobility condition_effects_dexterity condition_effects_stamina condition_effects_learning condition_effects_memory condition_effects_mental_health condition_effects_social_or_behavioral condition_effects_other condition_effects_prefer_not_to_say reasonable_preference_reason_homeless reasonable_preference_reason_unsatisfactory_housing reasonable_preference_reason_medical_grounds reasonable_preference_reason_avoid_hardship reasonable_preference_reason_do_not_know other_tenancy_type override_net_income_validation net_income_known] permitted end diff --git a/app/models/case_log.rb b/app/models/case_log.rb index f21b3338d..4d59ea91a 100644 --- a/app/models/case_log.rb +++ b/app/models/case_log.rb @@ -163,12 +163,6 @@ class CaseLog < ApplicationRecord end end - def hhmemb - if other_hhmemb.present? - other_hhmemb - end - end - def applicable_income_range return unless ecstat1 @@ -245,7 +239,7 @@ private dynamically_not_required << "incfreq" end - start_range = (other_hhmemb || 0) + 2 + start_range = (hhmemb || 0) + 2 (start_range..8).each do |n| dynamically_not_required << "age#{n}" dynamically_not_required << "sex#{n}" diff --git a/app/validations/household_validations.rb b/app/validations/household_validations.rb index d3536ae8a..b36972667 100644 --- a/app/validations/household_validations.rb +++ b/app/validations/household_validations.rb @@ -80,7 +80,7 @@ module HouseholdValidations record.errors.add :unittype_gn, "A bedsit can only have one bedroom" end - if !record.other_hhmemb.nil? && record.other_hhmemb.positive? && (record.unittype_gn.include?("Shared") && !record.beds.to_i.between?(1, 7)) + if !record.hhmemb.nil? && record.hhmemb.positive? && (record.unittype_gn.include?("Shared") && !record.beds.to_i.between?(1, 7)) record.errors.add :unittype_gn, "A shared house must have 1 to 7 bedrooms" end diff --git a/config/forms/2021_2022.json b/config/forms/2021_2022.json index 859e5fa14..f28753d14 100644 --- a/config/forms/2021_2022.json +++ b/config/forms/2021_2022.json @@ -104,7 +104,7 @@ "header": "About this log", "description": "", "questions": { - "startdate": { + "tenancy_start_date": { "check_answer_label": "When is the tenancy start date?", "header": "What is the tenancy start date?", "hint_text": "For example, 27 3 2007", @@ -332,7 +332,7 @@ "header": "", "description": "", "questions": { - "other_hhmemb": { + "hhmemb": { "check_answer_label": "Number of Other Household Members", "header": "How many other people are there in the household?", "hint_text": "The maximum number of others is 7", @@ -1027,6 +1027,18 @@ } } }, + "tenancy_start_date": { + "header": "", + "description": "", + "questions": { + "startdate": { + "check_answer_label": "When is the tenancy start date?", + "header": "What is the tenancy start date?", + "hint_text": "For example, 27 3 2007", + "type": "date" + } + } + }, "starter_tenancy": { "header": "", "description": "", diff --git a/db/migrate/20211111143319_add_other_members_column.rb b/db/migrate/20211111143319_add_other_members_column.rb deleted file mode 100644 index 2c6ca2658..000000000 --- a/db/migrate/20211111143319_add_other_members_column.rb +++ /dev/null @@ -1,7 +0,0 @@ -class AddOtherMembersColumn < ActiveRecord::Migration[6.1] - def change - change_table :case_logs, bulk: true do |t| - t.column :other_hhmemb, :integer - end - end -end diff --git a/db/schema.rb b/db/schema.rb index 5b1c02e62..ba9b956dd 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 2021_11_11_143319) do +ActiveRecord::Schema.define(version: 2021_11_10_140928) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -152,7 +152,6 @@ ActiveRecord::Schema.define(version: 2021_11_11_143319) do t.integer "mrcday" t.integer "mrcmonth" t.integer "mrcyear" - t.integer "other_hhmemb" t.index ["discarded_at"], name: "index_case_logs_on_discarded_at" end diff --git a/docs/api/DLUHC-CORE-Data.v1.json b/docs/api/DLUHC-CORE-Data.v1.json index 17560d14c..e13ad4f17 100644 --- a/docs/api/DLUHC-CORE-Data.v1.json +++ b/docs/api/DLUHC-CORE-Data.v1.json @@ -263,7 +263,7 @@ "prevten": "Private sector tenancy", "armed_forces": "Yes - a regular", "ecstat1": "Full-time - 30 hours or more", - "other_hhmemb": 7, + "hhmemb": 7, "relat2": "Partner", "age2": 32, "sex2": "Male", @@ -459,7 +459,7 @@ "Prefer not to say" ] }, - "other_hhmemb": { + "hhmemb": { "type": "number", "minimum": 0, "maximum": 7 @@ -1052,7 +1052,7 @@ "prevten", "armed_forces", "ecstat1", - "other_hhmemb", + "hhmemb", "relat2", "age2", "sex2", diff --git a/spec/features/case_log_spec.rb b/spec/features/case_log_spec.rb index b48572d62..aa53b8c7d 100644 --- a/spec/features/case_log_spec.rb +++ b/spec/features/case_log_spec.rb @@ -9,7 +9,7 @@ RSpec.describe "Test Features" do tenant_code: { type: "text", answer: "BZ737", path: "tenant_code" }, age1: { type: "numeric", answer: 25, path: "person_1_age" }, sex1: { type: "radio", answer: "Female", path: "person_1_gender" }, - other_hhmemb: { type: "numeric", answer: 2, path: "household_number_of_other_members" }, + hhmemb: { type: "numeric", answer: 2, path: "household_number_of_other_members" }, } def fill_in_number_question(case_log_id, question, value, path) @@ -265,7 +265,7 @@ RSpec.describe "Test Features" do let(:last_question_for_subsection) { "household_number_of_other_members" } it "redirects to the check answers page when answering the last question and clicking save and continue" do - fill_in_number_question(id, "other_hhmemb", 0, last_question_for_subsection) + fill_in_number_question(id, "hhmemb", 0, last_question_for_subsection) expect(page).to have_current_path("/case_logs/#{id}/#{subsection}/check_answers") end diff --git a/spec/fixtures/complete_case_log.json b/spec/fixtures/complete_case_log.json index 4656a04f8..97afaeaa0 100644 --- a/spec/fixtures/complete_case_log.json +++ b/spec/fixtures/complete_case_log.json @@ -8,8 +8,7 @@ "prevten": "Private sector tenancy", "armed_forces": "Yes - a regular", "ecstat1": "Full-time - 30 hours or more", - "other_hhmemb": 7, - "hhmemb": 8, + "hhmemb": 7, "relat2": "Partner", "age2": 32, "sex2": "Male", diff --git a/spec/fixtures/forms/test_form.json b/spec/fixtures/forms/test_form.json index 988d2176e..95ac050da 100644 --- a/spec/fixtures/forms/test_form.json +++ b/spec/fixtures/forms/test_form.json @@ -45,7 +45,7 @@ }, "household_number_of_other_members": { "questions": { - "other_hhmemb": { + "hhmemb": { "check_answer_label": "Number of Other Household Members", "header": "How many other people are there in the household?", "hint_text": "The maximum number of others is 1", diff --git a/spec/helpers/check_answers_helper_spec.rb b/spec/helpers/check_answers_helper_spec.rb index ac3000f6b..7ad04f081 100644 --- a/spec/helpers/check_answers_helper_spec.rb +++ b/spec/helpers/check_answers_helper_spec.rb @@ -6,7 +6,7 @@ RSpec.describe CheckAnswersHelper do FactoryBot.create( :case_log, :in_progress, - other_hhmemb: 1, + hhmemb: 1, relat2: "Partner", ) end diff --git a/spec/models/case_log_spec.rb b/spec/models/case_log_spec.rb index e663937db..438bf3c55 100644 --- a/spec/models/case_log_spec.rb +++ b/spec/models/case_log_spec.rb @@ -109,7 +109,7 @@ RSpec.describe Form, type: :model do expect { CaseLog.create!(unittype_gn: "Shared bungalow", beds: 8, - other_hhmemb: 1) + hhmemb: 1) }.to raise_error(ActiveRecord::RecordInvalid) end @@ -117,7 +117,7 @@ RSpec.describe Form, type: :model do expect { CaseLog.create!(unittype_gn: "Shared bungalow", beds: 4, - other_hhmemb: 0) + hhmemb: 0) }.to raise_error(ActiveRecord::RecordInvalid) end