From 807a331ba34aefc659ce6a38b44db07902433193 Mon Sep 17 00:00:00 2001 From: Manny Dinssa <44172848+Dinssa@users.noreply.github.com> Date: Thu, 3 Apr 2025 14:25:04 +0100 Subject: [PATCH] Keep old copy pre 2025 --- .../questions/person_working_situation.rb | 60 ++++++++++----- .../lettings/questions/working_situation1.rb | 46 ++++++++---- .../questions/buyer1_working_situation.rb | 6 +- .../questions/buyer2_working_situation.rb | 6 +- .../questions/person_working_situation.rb | 6 +- .../person_working_situation_spec.rb | 6 +- .../buyer1_working_situation_spec.rb | 30 ++++---- .../buyer2_working_situation_spec.rb | 73 +++++++++++++------ .../person_working_situation_spec.rb | 35 +++++++-- 9 files changed, 182 insertions(+), 86 deletions(-) diff --git a/app/models/form/lettings/questions/person_working_situation.rb b/app/models/form/lettings/questions/person_working_situation.rb index 6e53ef621..74e11d030 100644 --- a/app/models/form/lettings/questions/person_working_situation.rb +++ b/app/models/form/lettings/questions/person_working_situation.rb @@ -10,25 +10,47 @@ class Form::Lettings::Questions::PersonWorkingSituation < ::Form::Question end def answer_options - { "1" => { "value" => "Full-time – 30 hours or more per week" }, - "2" => { "value" => "Part-time – Less than 30 hours per week" }, - "7" => { "value" => "Full-time student" }, - "3" => { "value" => "In government training into work" }, - "4" => { "value" => "Jobseeker" }, - "6" => { "value" => "Not seeking work" }, - "8" => { "value" => "Unable to work because of long-term sickness or disability" }, - "5" => { "value" => "Retired" }, - "9" => { - "value" => "Child under 16", - "depends_on" => [ - { "age#{@person_index}_known" => 1 }, - { "age#{@person_index}_known" => nil }, - { "age#{@person_index}" => { "operator" => "<", "operand" => 16 } }, - ], - }, - "0" => { "value" => "Other" }, - "divider" => { "value" => true }, - "10" => { "value" => "Person prefers not to say" } } + if form.start_year_2025_or_later? + { "1" => { "value" => "Full-time – 30 hours or more per week" }, + "2" => { "value" => "Part-time – Less than 30 hours per week" }, + "7" => { "value" => "Full-time student" }, + "3" => { "value" => "In government training into work" }, + "4" => { "value" => "Jobseeker" }, + "6" => { "value" => "Not seeking work" }, + "8" => { "value" => "Unable to work because of long-term sickness or disability" }, + "5" => { "value" => "Retired" }, + "9" => { + "value" => "Child under 16", + "depends_on" => [ + { "age#{@person_index}_known" => 1 }, + { "age#{@person_index}_known" => nil }, + { "age#{@person_index}" => { "operator" => "<", "operand" => 16 } }, + ], + }, + "0" => { "value" => "Other" }, + "divider" => { "value" => true }, + "10" => { "value" => "Person prefers not to say" } } + else + { "1" => { "value" => "Full-time – 30 hours or more" }, + "2" => { "value" => "Part-time – Less than 30 hours" }, + "7" => { "value" => "Full-time student" }, + "3" => { "value" => "In government training into work" }, + "4" => { "value" => "Jobseeker" }, + "6" => { "value" => "Not seeking work" }, + "8" => { "value" => "Unable to work because of long term sick or disability" }, + "5" => { "value" => "Retired" }, + "9" => { + "value" => "Child under 16", + "depends_on" => [ + { "age#{@person_index}_known" => 1 }, + { "age#{@person_index}_known" => nil }, + { "age#{@person_index}" => { "operator" => "<", "operand" => 16 } }, + ], + }, + "0" => { "value" => "Other" }, + "divider" => { "value" => true }, + "10" => { "value" => "Person prefers not to say" } } + end end def question_number diff --git a/app/models/form/lettings/questions/working_situation1.rb b/app/models/form/lettings/questions/working_situation1.rb index 87f3c16c7..6098eb136 100644 --- a/app/models/form/lettings/questions/working_situation1.rb +++ b/app/models/form/lettings/questions/working_situation1.rb @@ -4,23 +4,41 @@ class Form::Lettings::Questions::WorkingSituation1 < ::Form::Question @id = "ecstat1" @type = "radio" @check_answers_card_number = 1 - @answer_options = ANSWER_OPTIONS + @answer_options = answer_options @question_number = QUESTION_NUMBER_FROM_YEAR[form.start_date.year] || QUESTION_NUMBER_FROM_YEAR[QUESTION_NUMBER_FROM_YEAR.keys.max] end - ANSWER_OPTIONS = { - "1" => { "value" => "Full-time – 30 hours or more per week" }, - "2" => { "value" => "Part-time – Less than 30 hours per week" }, - "7" => { "value" => "Full-time student" }, - "3" => { "value" => "In government training into work" }, - "4" => { "value" => "Jobseeker" }, - "6" => { "value" => "Not seeking work" }, - "8" => { "value" => "Unable to work because of long-term sickness or disability" }, - "5" => { "value" => "Retired" }, - "0" => { "value" => "Other" }, - "divider" => { "value" => true }, - "10" => { "value" => "Tenant prefers not to say" }, - }.freeze + def answer_options + if form.start_year_2025_or_later? + { + "1" => { "value" => "Full-time – 30 hours or more per week" }, + "2" => { "value" => "Part-time – Less than 30 hours per week" }, + "7" => { "value" => "Full-time student" }, + "3" => { "value" => "In government training into work" }, + "4" => { "value" => "Jobseeker" }, + "6" => { "value" => "Not seeking work" }, + "8" => { "value" => "Unable to work because of long-term sickness or disability" }, + "5" => { "value" => "Retired" }, + "0" => { "value" => "Other" }, + "divider" => { "value" => true }, + "10" => { "value" => "Tenant prefers not to say" }, + } + else + { + "1" => { "value" => "Full-time – 30 hours or more" }, + "2" => { "value" => "Part-time – Less than 30 hours" }, + "7" => { "value" => "Full-time student" }, + "3" => { "value" => "In government training into work" }, + "4" => { "value" => "Jobseeker" }, + "6" => { "value" => "Not seeking work" }, + "8" => { "value" => "Unable to work because of long term sick or disability" }, + "5" => { "value" => "Retired" }, + "0" => { "value" => "Other" }, + "divider" => { "value" => true }, + "10" => { "value" => "Tenant prefers not to say" }, + } + end + end QUESTION_NUMBER_FROM_YEAR = { 2023 => 37, 2024 => 36 }.freeze end diff --git a/app/models/form/sales/questions/buyer1_working_situation.rb b/app/models/form/sales/questions/buyer1_working_situation.rb index 48385868d..ea0e9e54f 100644 --- a/app/models/form/sales/questions/buyer1_working_situation.rb +++ b/app/models/form/sales/questions/buyer1_working_situation.rb @@ -30,12 +30,12 @@ class Form::Sales::Questions::Buyer1WorkingSituation < ::Form::Question }.freeze else { - "1" => { "value" => "Full-time – 30 hours or more per week" }, - "2" => { "value" => "Part-time – Less than 30 hours per week" }, + "1" => { "value" => "Full-time - 30 hours or more" }, + "2" => { "value" => "Part-time - Less than 30 hours" }, "3" => { "value" => "In government training into work" }, "4" => { "value" => "Jobseeker" }, "6" => { "value" => "Not seeking work" }, - "8" => { "value" => "Unable to work because of long-term sickness or disability" }, + "8" => { "value" => "Unable to work due to long term sick or disability" }, "5" => { "value" => "Retired" }, "0" => { "value" => "Other" }, "10" => { "value" => "Buyer prefers not to say" }, diff --git a/app/models/form/sales/questions/buyer2_working_situation.rb b/app/models/form/sales/questions/buyer2_working_situation.rb index 33d9c423e..32a7c93f4 100644 --- a/app/models/form/sales/questions/buyer2_working_situation.rb +++ b/app/models/form/sales/questions/buyer2_working_situation.rb @@ -36,12 +36,12 @@ class Form::Sales::Questions::Buyer2WorkingSituation < ::Form::Question }.freeze else { - "1" => { "value" => "Full-time – 30 hours or more per week" }, - "2" => { "value" => "Part-time – Less than 30 hours per week" }, + "1" => { "value" => "Full-time - 30 hours or more" }, + "2" => { "value" => "Part-time - Less than 30 hours" }, "3" => { "value" => "In government training into work" }, "4" => { "value" => "Jobseeker" }, "6" => { "value" => "Not seeking work" }, - "8" => { "value" => "Unable to work because of long-term sickness or disability" }, + "8" => { "value" => "Unable to work due to long term sick or disability" }, "5" => { "value" => "Retired" }, "0" => { "value" => "Other" }, "10" => { "value" => "Buyer prefers not to say" }, diff --git a/app/models/form/sales/questions/person_working_situation.rb b/app/models/form/sales/questions/person_working_situation.rb index 3cb3a2203..39c18a22a 100644 --- a/app/models/form/sales/questions/person_working_situation.rb +++ b/app/models/form/sales/questions/person_working_situation.rb @@ -40,12 +40,12 @@ class Form::Sales::Questions::PersonWorkingSituation < ::Form::Question } else { - "1" => { "value" => "Full-time – 30 hours or more per week" }, - "2" => { "value" => "Part-time – Less than 30 hours per week" }, + "1" => { "value" => "Full-time - 30 hours or more" }, + "2" => { "value" => "Part-time - Less than 30 hours" }, "3" => { "value" => "In government training into work" }, "4" => { "value" => "Jobseeker" }, "6" => { "value" => "Not seeking work" }, - "8" => { "value" => "Unable to work because of long-term sickness or disability" }, + "8" => { "value" => "Unable to work due to long term sick or disability" }, "5" => { "value" => "Retired" }, "0" => { "value" => "Other" }, "10" => { "value" => "Person prefers not to say" }, diff --git a/spec/models/form/lettings/questions/person_working_situation_spec.rb b/spec/models/form/lettings/questions/person_working_situation_spec.rb index 6b46fcc88..503c699b2 100644 --- a/spec/models/form/lettings/questions/person_working_situation_spec.rb +++ b/spec/models/form/lettings/questions/person_working_situation_spec.rb @@ -4,9 +4,13 @@ RSpec.describe Form::Lettings::Questions::PersonWorkingSituation, type: :model d subject(:question) { described_class.new(nil, question_definition, page, person_index:) } let(:question_definition) { nil } - let(:page) { instance_double(Form::Page, subsection: instance_double(Form::Subsection, form: instance_double(Form, start_date: Time.zone.local(2023, 4, 4)))) } + let(:page) { instance_double(Form::Page, subsection: instance_double(Form::Subsection, form: instance_double(Form, start_date: Time.zone.local(2025, 4, 4)))) } let(:person_index) { 2 } + before do + allow(page.subsection.form).to receive(:start_year_2025_or_later?).and_return(true) + end + it "has correct page" do expect(question.page).to eq(page) end diff --git a/spec/models/form/sales/questions/buyer1_working_situation_spec.rb b/spec/models/form/sales/questions/buyer1_working_situation_spec.rb index 573e732fe..d952a6fe6 100644 --- a/spec/models/form/sales/questions/buyer1_working_situation_spec.rb +++ b/spec/models/form/sales/questions/buyer1_working_situation_spec.rb @@ -24,21 +24,6 @@ RSpec.describe Form::Sales::Questions::Buyer1WorkingSituation, type: :model do expect(question.derived?(nil)).to be false end - it "has the correct answer_options" do - expect(question.answer_options).to eq({ - "1" => { "value" => "Full-time – 30 hours or more per week" }, - "2" => { "value" => "Part-time – Less than 30 hours per week" }, - "3" => { "value" => "In government training into work" }, - "4" => { "value" => "Jobseeker" }, - "6" => { "value" => "Not seeking work" }, - "8" => { "value" => "Unable to work because of long-term sickness or disability" }, - "5" => { "value" => "Retired" }, - "0" => { "value" => "Other" }, - "10" => { "value" => "Buyer prefers not to say" }, - "7" => { "value" => "Full-time student" }, - }) - end - context "with start year before 2025" do let(:form) { instance_double(Form, start_date: Time.zone.local(2024, 4, 1), start_year_2025_or_later?: false) } @@ -53,6 +38,21 @@ RSpec.describe Form::Sales::Questions::Buyer1WorkingSituation, type: :model do it "uses the new ordering for answer options" do expect(question.answer_options.keys).to eq(%w[1 2 3 4 5 6 7 8 0 10]) end + + it "has the correct answer_options" do + expect(question.answer_options).to eq({ + "1" => { "value" => "Full-time – 30 hours or more per week" }, + "2" => { "value" => "Part-time – Less than 30 hours per week" }, + "3" => { "value" => "In government training into work" }, + "4" => { "value" => "Jobseeker" }, + "6" => { "value" => "Not seeking work" }, + "8" => { "value" => "Unable to work because of long-term sickness or disability" }, + "5" => { "value" => "Retired" }, + "0" => { "value" => "Other" }, + "10" => { "value" => "Buyer prefers not to say" }, + "7" => { "value" => "Full-time student" }, + }) + end end it "has the correct check_answers_card_number" do diff --git a/spec/models/form/sales/questions/buyer2_working_situation_spec.rb b/spec/models/form/sales/questions/buyer2_working_situation_spec.rb index 710fa6bf6..84716dd24 100644 --- a/spec/models/form/sales/questions/buyer2_working_situation_spec.rb +++ b/spec/models/form/sales/questions/buyer2_working_situation_spec.rb @@ -26,32 +26,32 @@ RSpec.describe Form::Sales::Questions::Buyer2WorkingSituation, type: :model do it "has the correct answer_options" do expect(question.answer_options).to eq({ - "1" => { "value" => "Full-time – 30 hours or more per week" }, - "2" => { "value" => "Part-time – Less than 30 hours per week" }, - "3" => { "value" => "In government training into work" }, - "4" => { "value" => "Jobseeker" }, - "6" => { "value" => "Not seeking work" }, - "8" => { "value" => "Unable to work because of long-term sickness or disability" }, - "5" => { "value" => "Retired" }, - "0" => { "value" => "Other" }, - "10" => { "value" => "Buyer prefers not to say" }, - "7" => { "value" => "Full-time student" }, - "9" => { "value" => "Child under 16" }, + "1" => { "value" => "Full-time - 30 hours or more" }, + "2" => { "value" => "Part-time - Less than 30 hours" }, + "3" => { "value" => "In government training into work" }, + "4" => { "value" => "Jobseeker" }, + "6" => { "value" => "Not seeking work" }, + "8" => { "value" => "Unable to work due to long term sick or disability" }, + "5" => { "value" => "Retired" }, + "0" => { "value" => "Other" }, + "10" => { "value" => "Buyer prefers not to say" }, + "7" => { "value" => "Full-time student" }, + "9" => { "value" => "Child under 16" }, }) end it "has the correct displayed_answer_options" do expect(question.displayed_answer_options(nil)).to eq({ - "1" => { "value" => "Full-time – 30 hours or more per week" }, - "2" => { "value" => "Part-time – Less than 30 hours per week" }, - "3" => { "value" => "In government training into work" }, - "4" => { "value" => "Jobseeker" }, - "6" => { "value" => "Not seeking work" }, - "8" => { "value" => "Unable to work because of long-term sickness or disability" }, - "5" => { "value" => "Retired" }, - "0" => { "value" => "Other" }, - "10" => { "value" => "Buyer prefers not to say" }, - "7" => { "value" => "Full-time student" }, + "1" => { "value" => "Full-time - 30 hours or more" }, + "2" => { "value" => "Part-time - Less than 30 hours" }, + "3" => { "value" => "In government training into work" }, + "4" => { "value" => "Jobseeker" }, + "6" => { "value" => "Not seeking work" }, + "8" => { "value" => "Unable to work due to long term sick or disability" }, + "5" => { "value" => "Retired" }, + "0" => { "value" => "Other" }, + "10" => { "value" => "Buyer prefers not to say" }, + "7" => { "value" => "Full-time student" }, }) end @@ -77,6 +77,37 @@ RSpec.describe Form::Sales::Questions::Buyer2WorkingSituation, type: :model do it "uses the new ordering for displayed answer options" do expect(question.displayed_answer_options(nil).keys).to eq(%w[1 2 3 4 5 6 7 8 0 10]) end + + it "has the correct answer_options" do + expect(question.answer_options).to eq({ + "1" => { "value" => "Full-time – 30 hours or more per week" }, + "2" => { "value" => "Part-time – Less than 30 hours per week" }, + "3" => { "value" => "In government training into work" }, + "4" => { "value" => "Jobseeker" }, + "6" => { "value" => "Not seeking work" }, + "8" => { "value" => "Unable to work because of long-term sickness or disability" }, + "5" => { "value" => "Retired" }, + "0" => { "value" => "Other" }, + "10" => { "value" => "Buyer prefers not to say" }, + "7" => { "value" => "Full-time student" }, + "9" => { "value" => "Child under 16" }, + }) + end + + it "has the correct displayed_answer_options" do + expect(question.displayed_answer_options(nil)).to eq({ + "1" => { "value" => "Full-time – 30 hours or more per week" }, + "2" => { "value" => "Part-time – Less than 30 hours per week" }, + "3" => { "value" => "In government training into work" }, + "4" => { "value" => "Jobseeker" }, + "6" => { "value" => "Not seeking work" }, + "8" => { "value" => "Unable to work because of long-term sickness or disability" }, + "5" => { "value" => "Retired" }, + "0" => { "value" => "Other" }, + "10" => { "value" => "Buyer prefers not to say" }, + "7" => { "value" => "Full-time student" }, + }) + end end it "has the correct check_answers_card_number" do diff --git a/spec/models/form/sales/questions/person_working_situation_spec.rb b/spec/models/form/sales/questions/person_working_situation_spec.rb index 59107680a..c6a215741 100644 --- a/spec/models/form/sales/questions/person_working_situation_spec.rb +++ b/spec/models/form/sales/questions/person_working_situation_spec.rb @@ -23,22 +23,22 @@ RSpec.describe Form::Sales::Questions::PersonWorkingSituation, type: :model do it "has the correct answer_options" do expect(question.answer_options).to eq({ - "1" => { "value" => "Full-time – 30 hours or more per week" }, - "2" => { "value" => "Part-time – Less than 30 hours per week" }, + "1" => { "value" => "Full-time - 30 hours or more" }, + "2" => { "value" => "Part-time - Less than 30 hours" }, "3" => { "value" => "In government training into work" }, "4" => { "value" => "Jobseeker" }, "6" => { "value" => "Not seeking work" }, - "8" => { "value" => "Unable to work because of long-term sickness or disability" }, + "8" => { "value" => "Unable to work due to long term sick or disability" }, "5" => { "value" => "Retired" }, "0" => { "value" => "Other" }, "10" => { "value" => "Person prefers not to say" }, "7" => { "value" => "Full-time student" }, "9" => { "value" => "Child under 16", "depends_on" => - [{ "saledate" => { "operator" => "<", "operand" => Time.zone.local(2024, 4, 1) } }, - { "age2_known" => 1 }, - { "age2_known" => nil }, - { "age2" => { "operator" => "<", "operand" => 16 } }] }, + [{ "saledate" => { "operator" => "<", "operand" => Time.zone.local(2024, 4, 1) } }, + { "age2_known" => 1 }, + { "age2_known" => nil }, + { "age2" => { "operator" => "<", "operand" => 16 } }] }, }) end @@ -56,6 +56,27 @@ RSpec.describe Form::Sales::Questions::PersonWorkingSituation, type: :model do it "uses the new ordering for answer options" do expect(question.answer_options.keys).to eq(%w[1 2 3 4 5 6 7 8 9 0 10]) end + + it "has the correct answer_options" do + expect(question.answer_options).to eq({ + "1" => { "value" => "Full-time – 30 hours or more per week" }, + "2" => { "value" => "Part-time – Less than 30 hours per week" }, + "3" => { "value" => "In government training into work" }, + "4" => { "value" => "Jobseeker" }, + "6" => { "value" => "Not seeking work" }, + "8" => { "value" => "Unable to work because of long-term sickness or disability" }, + "5" => { "value" => "Retired" }, + "0" => { "value" => "Other" }, + "10" => { "value" => "Person prefers not to say" }, + "7" => { "value" => "Full-time student" }, + "9" => { "value" => "Child under 16", + "depends_on" => + [{ "saledate" => { "operator" => "<", "operand" => Time.zone.local(2024, 4, 1) } }, + { "age2_known" => 1 }, + { "age2_known" => nil }, + { "age2" => { "operator" => "<", "operand" => 16 } }] }, + }) + end end context "when person 2" do