diff --git a/spec/fixtures/variable_definitions/lettings_download_26_27.csv b/spec/fixtures/variable_definitions/lettings_download_26_27.csv new file mode 100644 index 000000000..2cc95f184 --- /dev/null +++ b/spec/fixtures/variable_definitions/lettings_download_26_27.csv @@ -0,0 +1 @@ +working_situation_illness_check,The following soft validation was confirmed: You have said that at least one person's situation is 'Unable to work because of long-term sickness or disability'. diff --git a/spec/lib/tasks/log_variable_definitions_spec.rb b/spec/lib/tasks/log_variable_definitions_spec.rb index 7fdeb66e4..8bae5a4d0 100644 --- a/spec/lib/tasks/log_variable_definitions_spec.rb +++ b/spec/lib/tasks/log_variable_definitions_spec.rb @@ -14,7 +14,7 @@ RSpec.describe "log_variable_definitions" do end it "adds CsvVariableDefinition records from each file in the specified directory" do - expect { task.invoke(path) }.to change(CsvVariableDefinition, :count).by(416) + expect { task.invoke(path) }.to change(CsvVariableDefinition, :count).by(417) end it "handles an empty directory without errors" do @@ -34,7 +34,7 @@ RSpec.describe "log_variable_definitions" do task.invoke(path) second_run_count = CsvVariableDefinition.count - expect(first_run_count).to eq(initial_count + 416) + expect(first_run_count).to eq(initial_count + 417) expect(second_run_count).to eq(first_run_count) end end diff --git a/spec/models/form/lettings/questions/working_situation_illness_check_spec.rb b/spec/models/form/lettings/questions/working_situation_illness_check_spec.rb new file mode 100644 index 000000000..271fc3928 --- /dev/null +++ b/spec/models/form/lettings/questions/working_situation_illness_check_spec.rb @@ -0,0 +1,49 @@ +require "rails_helper" + +RSpec.describe Form::Lettings::Questions::WorkingSituationIllnessCheck, type: :model do + subject(:question) { described_class.new(question_id, question_definition, page, person_index: 1) } + + let(:question_id) { nil } + let(:question_definition) { nil } + let(:page) { instance_double(Form::Page, copy_key: nil) } + + it "has correct page" do + expect(question.page).to eq(page) + end + + it "has the correct id" do + expect(question.id).to eq("working_situation_illness_check") + end + + it "has the correct type" do + expect(question.type).to eq("interruption_screen") + end + + it "is not marked as derived" do + expect(question.derived?(nil)).to be false + end + + it "has a correct check_answers_card_number" do + expect(question.check_answers_card_number).to eq(1) + end + + it "has the correct answer_options" do + expect(question.answer_options).to eq({ + "0" => { "value" => "Yes" }, + "1" => { "value" => "No" }, + }) + end + + it "has the correct hidden_in_check_answers" do + expect(question.hidden_in_check_answers).to eq({ + "depends_on" => [ + { + "working_situation_illness_check" => 0, + }, + { + "working_situation_illness_check" => 1, + }, + ], + }) + end +end diff --git a/spec/models/form/lettings/subsections/household_characteristics_spec.rb b/spec/models/form/lettings/subsections/household_characteristics_spec.rb index d49fdc62b..3269514d2 100644 --- a/spec/models/form/lettings/subsections/household_characteristics_spec.rb +++ b/spec/models/form/lettings/subsections/household_characteristics_spec.rb @@ -10,17 +10,18 @@ RSpec.describe Form::Lettings::Subsections::HouseholdCharacteristics, type: :mod before do allow(section).to receive(:form).and_return(form) + allow(form).to receive(:start_year_2024_or_later?).and_return(false) allow(form).to receive(:start_year_2025_or_later?).and_return(false) + allow(form).to receive(:start_year_2026_or_later?).and_return(false) end it "has correct section" do expect(household_characteristics.section).to eq(section) end - context "with start year 2024" do + context "with start year 2024", metadata: { year: 24 } do before do allow(form).to receive(:start_year_2024_or_later?).and_return(true) - allow(form).to receive(:start_year_2026_or_later?).and_return(false) end it "has correct pages" do @@ -172,11 +173,10 @@ RSpec.describe Form::Lettings::Subsections::HouseholdCharacteristics, type: :mod end end - context "with start year 2025" do + context "with start year 2025", metadata: { year: 25 } do before do allow(form).to receive(:start_year_2024_or_later?).and_return(true) allow(form).to receive(:start_year_2025_or_later?).and_return(true) - allow(form).to receive(:start_year_2026_or_later?).and_return(false) end it "has correct pages" do @@ -328,7 +328,7 @@ RSpec.describe Form::Lettings::Subsections::HouseholdCharacteristics, type: :mod end end - context "with start year >= 2026" do + context "with start year 2026", metadata: { year: 26 } do before do allow(form).to receive(:start_year_2024_or_later?).and_return(true) allow(form).to receive(:start_year_2025_or_later?).and_return(true) @@ -360,6 +360,7 @@ RSpec.describe Form::Lettings::Subsections::HouseholdCharacteristics, type: :mod lead_tenant_working_situation working_situation_lead_tenant_under_retirement_value_check working_situation_lead_tenant_over_retirement_value_check + working_situation_lead_tenant_long_term_illness_check person_2_known person_2_age person_2_lead_partner @@ -375,6 +376,7 @@ RSpec.describe Form::Lettings::Subsections::HouseholdCharacteristics, type: :mod person_2_working_situation working_situation_2_under_retirement_value_check working_situation_2_over_retirement_value_check + working_situation_2_long_term_illness_check person_3_known person_3_age person_3_lead_partner @@ -390,6 +392,7 @@ RSpec.describe Form::Lettings::Subsections::HouseholdCharacteristics, type: :mod person_3_working_situation working_situation_3_under_retirement_value_check working_situation_3_over_retirement_value_check + working_situation_3_long_term_illness_check person_4_known person_4_age person_4_lead_partner @@ -405,6 +408,7 @@ RSpec.describe Form::Lettings::Subsections::HouseholdCharacteristics, type: :mod person_4_working_situation working_situation_4_under_retirement_value_check working_situation_4_over_retirement_value_check + working_situation_4_long_term_illness_check person_5_known person_5_age person_5_lead_partner @@ -420,6 +424,7 @@ RSpec.describe Form::Lettings::Subsections::HouseholdCharacteristics, type: :mod person_5_working_situation working_situation_5_under_retirement_value_check working_situation_5_over_retirement_value_check + working_situation_5_long_term_illness_check person_6_known person_6_age person_6_lead_partner @@ -435,6 +440,7 @@ RSpec.describe Form::Lettings::Subsections::HouseholdCharacteristics, type: :mod person_6_working_situation working_situation_6_under_retirement_value_check working_situation_6_over_retirement_value_check + working_situation_6_long_term_illness_check person_7_known person_7_age person_7_lead_partner @@ -450,6 +456,7 @@ RSpec.describe Form::Lettings::Subsections::HouseholdCharacteristics, type: :mod person_7_working_situation working_situation_7_under_retirement_value_check working_situation_7_over_retirement_value_check + working_situation_7_long_term_illness_check person_8_known person_8_age person_8_lead_partner @@ -465,6 +472,7 @@ RSpec.describe Form::Lettings::Subsections::HouseholdCharacteristics, type: :mod person_8_working_situation working_situation_8_under_retirement_value_check working_situation_8_over_retirement_value_check + working_situation_8_long_term_illness_check ], ) end diff --git a/spec/models/form/lettings/subsections/household_needs_spec.rb b/spec/models/form/lettings/subsections/household_needs_spec.rb index dcd957601..7c3a2a505 100644 --- a/spec/models/form/lettings/subsections/household_needs_spec.rb +++ b/spec/models/form/lettings/subsections/household_needs_spec.rb @@ -8,25 +8,61 @@ RSpec.describe Form::Lettings::Subsections::HouseholdNeeds, type: :model do let(:form) { instance_double(Form, start_date: Time.zone.local(2024, 4, 1)) } let(:section) { instance_double(Form::Lettings::Sections::Household, form:) } + before do + allow(form).to receive(:start_year_2025_or_later?).and_return(false) + allow(form).to receive(:start_year_2026_or_later?).and_return(false) + end + it "has correct section" do expect(household_needs.section).to eq(section) end - it "has correct pages" do - expect(household_needs.pages.map(&:id)).to eq( - %w[ - armed_forces - armed_forces_serving - armed_forces_injured - pregnant - no_females_pregnant_household_value_check - females_in_soft_age_range_in_pregnant_household_value_check - access_needs_exist - type_of_access_needs - health_conditions - health_condition_effects - ], - ) + context "with start year >= 2025", metadata: { year: 25 } do + before do + allow(form).to receive(:start_year_2025_or_later?).and_return(true) + end + + it "has correct pages" do + expect(household_needs.pages.map(&:id)).to eq( + %w[ + armed_forces + armed_forces_serving + armed_forces_injured + pregnant + no_females_pregnant_household_value_check + females_in_soft_age_range_in_pregnant_household_value_check + access_needs_exist + type_of_access_needs + health_conditions + health_condition_effects + ], + ) + end + end + + context "with start year >= 2026", metadata: { year: 26 } do + before do + allow(form).to receive(:start_year_2025_or_later?).and_return(true) + allow(form).to receive(:start_year_2026_or_later?).and_return(true) + end + + it "has correct pages" do + expect(household_needs.pages.map(&:id)).to eq( + %w[ + armed_forces + armed_forces_serving + armed_forces_injured + pregnant + no_females_pregnant_household_value_check + females_in_soft_age_range_in_pregnant_household_value_check + access_needs_exist + type_of_access_needs + health_conditions + working_situation_long_term_illness_check + health_condition_effects + ], + ) + end end it "has the correct id" do diff --git a/spec/models/validations/soft_validations_spec.rb b/spec/models/validations/soft_validations_spec.rb index 0027c2d71..6c39824c5 100644 --- a/spec/models/validations/soft_validations_spec.rb +++ b/spec/models/validations/soft_validations_spec.rb @@ -1354,4 +1354,42 @@ RSpec.describe Validations::SoftValidations do expect(record).to be_reasonother_might_be_existing_category end end + + describe "at_least_one_working_situation_is_sickness_and_household_sickness_is_no" do + it "returns true if one person has working situation as illness and household sickness is no" do + record.illness = 2 + record.hhmemb = 2 + record.ecstat1 = 8 + record.ecstat2 = 1 + + expect(record.at_least_one_working_situation_is_sickness_and_household_sickness_is_no?).to be true + end + + it "returns true if all people has working situation as illness and household sickness is no" do + record.illness = 2 + record.hhmemb = 2 + record.ecstat1 = 8 + record.ecstat2 = 8 + + expect(record.at_least_one_working_situation_is_sickness_and_household_sickness_is_no?).to be true + end + + it "returns false if household sickness is yes" do + record.illness = 1 + record.hhmemb = 2 + record.ecstat1 = 8 + record.ecstat2 = 1 + + expect(record.at_least_one_working_situation_is_sickness_and_household_sickness_is_no?).to be false + end + + it "returns false if no working situation is illness" do + record.illness = 2 + record.hhmemb = 2 + record.ecstat1 = 1 + record.ecstat2 = 1 + + expect(record.at_least_one_working_situation_is_sickness_and_household_sickness_is_no?).to be false + end + end end diff --git a/spec/services/bulk_upload/lettings/year2026/row_parser_spec.rb b/spec/services/bulk_upload/lettings/year2026/row_parser_spec.rb index 6e37c82b3..e4b3150fe 100644 --- a/spec/services/bulk_upload/lettings/year2026/row_parser_spec.rb +++ b/spec/services/bulk_upload/lettings/year2026/row_parser_spec.rb @@ -197,7 +197,7 @@ RSpec.describe BulkUpload::Lettings::Year2026::RowParser do field_82: "1", field_83: "0", - field_85: "2", + field_85: "3", field_96: "11", field_97: "2",