magicmilo 3 years ago
parent
commit
d1ae40dc3b
  1. 2
      app/admin/case_logs.rb
  2. 8
      app/models/case_log.rb
  3. 2
      app/validations/household_validations.rb
  4. 16
      config/forms/2021_2022.json
  5. 7
      db/migrate/20211111143319_add_other_members_column.rb
  6. 3
      db/schema.rb
  7. 6
      docs/api/DLUHC-CORE-Data.v1.json
  8. 4
      spec/features/case_log_spec.rb
  9. 3
      spec/fixtures/complete_case_log.json
  10. 2
      spec/fixtures/forms/test_form.json
  11. 2
      spec/helpers/check_answers_helper_spec.rb
  12. 4
      spec/models/case_log_spec.rb

2
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 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 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
end

8
app/models/case_log.rb

@ -163,6 +163,12 @@ class CaseLog < ApplicationRecord
end
end
def hhmemb
if other_hhmemb.present?
other_hhmemb
end
end
def applicable_income_range
return unless ecstat1
@ -239,7 +245,7 @@ private
dynamically_not_required << "incfreq"
end
start_range = (hhmemb || 0) + 2
start_range = (other_hhmemb || 0) + 2
(start_range..8).each do |n|
dynamically_not_required << "age#{n}"
dynamically_not_required << "sex#{n}"

2
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.hhmemb.nil? && record.hhmemb.positive? && (record.unittype_gn.include?("Shared") && !record.beds.to_i.between?(1, 7))
if !record.other_hhmemb.nil? && record.other_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

16
config/forms/2021_2022.json

@ -104,7 +104,7 @@
"header": "About this log",
"description": "",
"questions": {
"tenancy_start_date": {
"startdate": {
"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": {
"hhmemb": {
"other_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,18 +1027,6 @@
}
}
},
"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": "",

7
db/migrate/20211111143319_add_other_members_column.rb

@ -0,0 +1,7 @@
class AddOtherMembersColumn < ActiveRecord::Migration[6.1]
def change
change_table :case_logs, bulk: true do |t|
t.column :other_hhmemb, :integer
end
end
end

3
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_10_140928) do
ActiveRecord::Schema.define(version: 2021_11_11_143319) do
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
@ -152,6 +152,7 @@ ActiveRecord::Schema.define(version: 2021_11_10_140928) 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

6
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",
"hhmemb": 7,
"other_hhmemb": 7,
"relat2": "Partner",
"age2": 32,
"sex2": "Male",
@ -459,7 +459,7 @@
"Prefer not to say"
]
},
"hhmemb": {
"other_hhmemb": {
"type": "number",
"minimum": 0,
"maximum": 7
@ -1052,7 +1052,7 @@
"prevten",
"armed_forces",
"ecstat1",
"hhmemb",
"other_hhmemb",
"relat2",
"age2",
"sex2",

4
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" },
hhmemb: { type: "numeric", answer: 2, path: "household_number_of_other_members" },
other_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, "hhmemb", 0, last_question_for_subsection)
fill_in_number_question(id, "other_hhmemb", 0, last_question_for_subsection)
expect(page).to have_current_path("/case_logs/#{id}/#{subsection}/check_answers")
end

3
spec/fixtures/complete_case_log.json vendored

@ -8,7 +8,8 @@
"prevten": "Private sector tenancy",
"armed_forces": "Yes - a regular",
"ecstat1": "Full-time - 30 hours or more",
"hhmemb": 7,
"other_hhmemb": 7,
"hhmemb": 8,
"relat2": "Partner",
"age2": 32,
"sex2": "Male",

2
spec/fixtures/forms/test_form.json vendored

@ -45,7 +45,7 @@
},
"household_number_of_other_members": {
"questions": {
"hhmemb": {
"other_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",

2
spec/helpers/check_answers_helper_spec.rb

@ -6,7 +6,7 @@ RSpec.describe CheckAnswersHelper do
FactoryBot.create(
:case_log,
:in_progress,
hhmemb: 1,
other_hhmemb: 1,
relat2: "Partner",
)
end

4
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,
hhmemb: 1)
other_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,
hhmemb: 0)
other_hhmemb: 0)
}.to raise_error(ActiveRecord::RecordInvalid)
end

Loading…
Cancel
Save