From 4ff944a6a1dab403da05b998066658f33c2b3cce Mon Sep 17 00:00:00 2001 From: Manny Dinssa <44172848+Dinssa@users.noreply.github.com> Date: Wed, 19 Feb 2025 17:26:35 +0000 Subject: [PATCH] Add some question number tests --- ...ime_property_let_as_social_housing_spec.rb | 18 +++++++++++++ .../form/lettings/questions/joint_spec.rb | 24 +++++++++++++++++ .../models/form/lettings/questions/la_spec.rb | 24 +++++++++++++++++ .../questions/previous_let_type_spec.rb | 12 +++++++++ .../form/lettings/questions/rsnvac_spec.rb | 24 +++++++++++++++-- .../form/lettings/questions/sheltered_spec.rb | 12 +++++++++ .../questions/starter_tenancy_type_spec.rb | 18 +++++++++++++ .../tenancy_length_affordable_rent_spec.rb | 27 ++++++++++++++++++- .../tenancy_length_intermediate_rent_spec.rb | 27 ++++++++++++++++++- .../questions/tenancy_length_periodic_spec.rb | 27 ++++++++++++++++++- .../lettings/questions/tenancy_length_spec.rb | 27 ++++++++++++++++++- .../lettings/questions/tenancy_other_spec.rb | 27 ++++++++++++++++++- .../lettings/questions/tenancy_type_spec.rb | 21 ++++++++++++++- 13 files changed, 280 insertions(+), 8 deletions(-) diff --git a/spec/models/form/lettings/questions/first_time_property_let_as_social_housing_spec.rb b/spec/models/form/lettings/questions/first_time_property_let_as_social_housing_spec.rb index 756f5e84e..552734991 100644 --- a/spec/models/form/lettings/questions/first_time_property_let_as_social_housing_spec.rb +++ b/spec/models/form/lettings/questions/first_time_property_let_as_social_housing_spec.rb @@ -33,6 +33,8 @@ RSpec.describe Form::Lettings::Questions::FirstTimePropertyLetAsSocialHousing, t end context "with 2024/25 form" do + let(:form) { instance_double(Form, start_date: Time.zone.local(2024, 4, 1)) } + before do allow(form).to receive(:start_year_2024_or_later?).and_return(true) end @@ -43,5 +45,21 @@ RSpec.describe Form::Lettings::Questions::FirstTimePropertyLetAsSocialHousing, t "0" => { "value" => "No", "hint" => "This is a re-let of existing social housing stock." }, }) end + + it "has the correct question number" do + expect(question.question_number).to eq(15) + end + end + + context "with 2025/26 form" do + let(:form) { instance_double(Form, start_date: Time.zone.local(2025, 4, 1)) } + + before do + allow(form).to receive(:start_year_2024_or_later?).and_return(true) + end + + it "has the correct question number" do + expect(question.question_number).to eq(12) + end end end diff --git a/spec/models/form/lettings/questions/joint_spec.rb b/spec/models/form/lettings/questions/joint_spec.rb index d856e9c18..2a10bc5cf 100644 --- a/spec/models/form/lettings/questions/joint_spec.rb +++ b/spec/models/form/lettings/questions/joint_spec.rb @@ -39,4 +39,28 @@ RSpec.describe Form::Lettings::Questions::Joint, type: :model do it "is not marked as derived" do expect(question.derived?(nil)).to be false end + + context "with 2024/25 form" do + let(:form) { instance_double(Form, start_date: Time.zone.local(2024, 4, 1)) } + + before do + allow(form).to receive(:start_year_2024_or_later?).and_return(true) + end + + it "has the correct question number" do + expect(question.question_number).to eq(25) + end + end + + context "with 2025/26 form" do + let(:form) { instance_double(Form, start_date: Time.zone.local(2025, 4, 1)) } + + before do + allow(form).to receive(:start_year_2024_or_later?).and_return(true) + end + + it "has the correct question number" do + expect(question.question_number).to eq(26) + end + end end diff --git a/spec/models/form/lettings/questions/la_spec.rb b/spec/models/form/lettings/questions/la_spec.rb index 5f8d650f4..9812500c6 100644 --- a/spec/models/form/lettings/questions/la_spec.rb +++ b/spec/models/form/lettings/questions/la_spec.rb @@ -310,4 +310,28 @@ RSpec.describe Form::Lettings::Questions::La, type: :model do "E06000065" => "North Yorkshire", }) end + + context "with 2024/25 form" do + let(:start_date) { Time.utc(2024, 4, 1) } + + before do + allow(subsection.form).to receive(:start_year_2024_or_later?).and_return(true) + end + + it "has the correct question number" do + expect(question.question_number).to eq(14) + end + end + + context "with 2025/26 form" do + let(:start_date) { Time.utc(2025, 4, 1) } + + before do + allow(subsection.form).to receive(:start_year_2024_or_later?).and_return(true) + end + + it "has the correct question number" do + expect(question.question_number).to eq(18) + end + end end diff --git a/spec/models/form/lettings/questions/previous_let_type_spec.rb b/spec/models/form/lettings/questions/previous_let_type_spec.rb index 856d88bf5..27ad8b0b0 100644 --- a/spec/models/form/lettings/questions/previous_let_type_spec.rb +++ b/spec/models/form/lettings/questions/previous_let_type_spec.rb @@ -44,6 +44,8 @@ RSpec.describe Form::Lettings::Questions::PreviousLetType, type: :model do end context "with collection year on or after 2024" do + let(:form) { instance_double(Form, start_date: Time.zone.local(2024, 4, 1)) } + before do allow(form).to receive(:start_year_2024_or_later?).and_return(true) end @@ -60,9 +62,15 @@ RSpec.describe Form::Lettings::Questions::PreviousLetType, type: :model do "3" => { "value" => "Don’t know" }, }) end + + it "has the correct question number" do + expect(question.question_number).to eq(17) + end end context "with collection year on or after 2025" do + let(:form) { instance_double(Form, start_date: Time.zone.local(2025, 4, 1)) } + before do allow(form).to receive(:start_year_2025_or_later?).and_return(true) end @@ -80,5 +88,9 @@ RSpec.describe Form::Lettings::Questions::PreviousLetType, type: :model do "3" => { "value" => "Don’t know" }, }) end + + it "has the correct question number" do + expect(question.question_number).to eq(14) + end end end diff --git a/spec/models/form/lettings/questions/rsnvac_spec.rb b/spec/models/form/lettings/questions/rsnvac_spec.rb index 5eb37ddb5..629c0f423 100644 --- a/spec/models/form/lettings/questions/rsnvac_spec.rb +++ b/spec/models/form/lettings/questions/rsnvac_spec.rb @@ -76,7 +76,13 @@ RSpec.describe Form::Lettings::Questions::Rsnvac, type: :model do end end + it "has the correct check_answers_card_number" do + expect(question.check_answers_card_number).to eq(0) + end + context "with 2024/25 form" do + let(:form) { instance_double(Form, start_date: Time.zone.local(2024, 4, 1)) } + before do allow(form).to receive(:start_year_2024_or_later?).and_return(true) end @@ -129,9 +135,23 @@ RSpec.describe Form::Lettings::Questions::Rsnvac, type: :model do }, }) end + + it "has the correct question number" do + expect(question.question_number).to eq(18) + end end - it "has the correct check_answers_card_number" do - expect(question.check_answers_card_number).to eq(0) + context "with 2025/26 form" do + let(:form) { instance_double(Form, start_date: Time.zone.local(2025, 4, 1)) } + + before do + allow(form).to receive(:start_year_2024_or_later?).and_return(true) + end + + it "has the correct question number" do + expect(question.question_number).to eq(15) + end end + + end diff --git a/spec/models/form/lettings/questions/sheltered_spec.rb b/spec/models/form/lettings/questions/sheltered_spec.rb index 7b3ee9d86..4ff9268da 100644 --- a/spec/models/form/lettings/questions/sheltered_spec.rb +++ b/spec/models/form/lettings/questions/sheltered_spec.rb @@ -26,6 +26,8 @@ RSpec.describe Form::Lettings::Questions::Sheltered, type: :model do end context "with 2024/25 form" do + let(:form) { instance_double(Form, start_date: Time.zone.local(2024, 4, 1)) } + 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(false) @@ -42,9 +44,15 @@ RSpec.describe Form::Lettings::Questions::Sheltered, type: :model do "4" => { "value" => "Don’t know" }, }) end + + it "has the correct question number" do + expect(question.question_number).to eq(29) + end end context "with 2025/26 form" do + let(:form) { instance_double(Form, start_date: Time.zone.local(2025, 4, 1)) } + 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) @@ -60,6 +68,10 @@ RSpec.describe Form::Lettings::Questions::Sheltered, type: :model do "4" => { "value" => "Don’t know" }, }) end + + it "has the correct question number" do + expect(question.question_number).to eq(25) + end end it "is not marked as derived" do diff --git a/spec/models/form/lettings/questions/starter_tenancy_type_spec.rb b/spec/models/form/lettings/questions/starter_tenancy_type_spec.rb index 1100796c8..b6ae1ed92 100644 --- a/spec/models/form/lettings/questions/starter_tenancy_type_spec.rb +++ b/spec/models/form/lettings/questions/starter_tenancy_type_spec.rb @@ -49,6 +49,8 @@ RSpec.describe Form::Lettings::Questions::StarterTenancyType, type: :model do end context "with 2024/25 form" do + let(:form) { instance_double(Form, start_date: Time.zone.local(2024, 4, 1)) } + before do allow(form).to receive(:start_year_2024_or_later?).and_return(true) end @@ -84,5 +86,21 @@ RSpec.describe Form::Lettings::Questions::StarterTenancyType, type: :model do }, ) end + + it "has the correct question number" do + expect(question.question_number).to eq(27) + end + end + + context "with 2025/26 form" do + let(:form) { instance_double(Form, start_date: Time.zone.local(2025, 4, 1)) } + + before do + allow(form).to receive(:start_year_2024_or_later?).and_return(true) + end + + it "has the correct question number" do + expect(question.question_number).to eq(28) + end end end diff --git a/spec/models/form/lettings/questions/tenancy_length_affordable_rent_spec.rb b/spec/models/form/lettings/questions/tenancy_length_affordable_rent_spec.rb index ba9a72001..2763bfd42 100644 --- a/spec/models/form/lettings/questions/tenancy_length_affordable_rent_spec.rb +++ b/spec/models/form/lettings/questions/tenancy_length_affordable_rent_spec.rb @@ -7,7 +7,8 @@ RSpec.describe Form::Lettings::Questions::TenancyLengthAffordableRent, type: :mo let(:question_definition) { nil } let(:page) { instance_double(Form::Page, id: "affordable_tenancy_length") } let(:subsection) { instance_double(Form::Subsection) } - let(:form) { instance_double(Form, start_date: Time.zone.local(2023, 4, 1)) } + let(:form) { instance_double(Form, start_date:) } + let(:start_date) { Time.utc(2023, 4, 1) } before do allow(form).to receive(:start_year_2024_or_later?).and_return(false) @@ -26,4 +27,28 @@ RSpec.describe Form::Lettings::Questions::TenancyLengthAffordableRent, type: :mo it "has the correct type" do expect(question.type).to eq("numeric") end + + context "with 2024/25 form" do + let(:start_date) { Time.utc(2024, 4, 1) } + + before do + allow(form).to receive(:start_year_2024_or_later?).and_return(true) + end + + it "has the correct question number" do + expect(question.question_number).to eq(28) + end + end + + context "with 2025/26 form" do + let(:start_date) { Time.utc(2025, 4, 1) } + + before do + allow(form).to receive(:start_year_2024_or_later?).and_return(true) + end + + it "has the correct question number" do + expect(question.question_number).to eq(29) + end + end end diff --git a/spec/models/form/lettings/questions/tenancy_length_intermediate_rent_spec.rb b/spec/models/form/lettings/questions/tenancy_length_intermediate_rent_spec.rb index 55b51ccfa..5b58d55db 100644 --- a/spec/models/form/lettings/questions/tenancy_length_intermediate_rent_spec.rb +++ b/spec/models/form/lettings/questions/tenancy_length_intermediate_rent_spec.rb @@ -7,7 +7,8 @@ RSpec.describe Form::Lettings::Questions::TenancyLengthIntermediateRent, type: : let(:question_definition) { nil } let(:page) { instance_double(Form::Page, id: "intermediate_tenancy_length") } let(:subsection) { instance_double(Form::Subsection) } - let(:form) { instance_double(Form, start_date: Time.zone.local(2023, 4, 1)) } + let(:form) { instance_double(Form, start_date:) } + let(:start_date) { Time.utc(2023, 4, 1) } before do allow(form).to receive(:start_year_2024_or_later?).and_return(false) @@ -26,4 +27,28 @@ RSpec.describe Form::Lettings::Questions::TenancyLengthIntermediateRent, type: : it "has the correct type" do expect(question.type).to eq("numeric") end + + context "with 2024/25 form" do + let(:start_date) { Time.utc(2024, 4, 1) } + + before do + allow(form).to receive(:start_year_2024_or_later?).and_return(true) + end + + it "has the correct question number" do + expect(question.question_number).to eq(28) + end + end + + context "with 2025/26 form" do + let(:start_date) { Time.utc(2025, 4, 1) } + + before do + allow(form).to receive(:start_year_2024_or_later?).and_return(true) + end + + it "has the correct question number" do + expect(question.question_number).to eq(29) + end + end end diff --git a/spec/models/form/lettings/questions/tenancy_length_periodic_spec.rb b/spec/models/form/lettings/questions/tenancy_length_periodic_spec.rb index 449677736..4bb511dbc 100644 --- a/spec/models/form/lettings/questions/tenancy_length_periodic_spec.rb +++ b/spec/models/form/lettings/questions/tenancy_length_periodic_spec.rb @@ -5,7 +5,8 @@ RSpec.describe Form::Lettings::Questions::TenancyLengthPeriodic, type: :model do let(:question_id) { nil } 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, 1))), id: "periodic_tenancy_length") } + let(:page) { instance_double(Form::Page, subsection: instance_double(Form::Subsection, form: instance_double(Form, start_date:)), id: "periodic_tenancy_length") } + let(:start_date) { Time.utc(2023, 4, 1) } it "has correct page" do expect(question.page).to eq(page) @@ -18,4 +19,28 @@ RSpec.describe Form::Lettings::Questions::TenancyLengthPeriodic, type: :model do it "has the correct type" do expect(question.type).to eq("numeric") end + + context "with 2024/25 form" do + let(:start_date) { Time.utc(2024, 4, 1) } + + before do + allow(page.subsection.form).to receive(:start_year_2024_or_later?).and_return(true) + end + + it "has the correct question number" do + expect(question.question_number).to eq(28) + end + end + + context "with 2025/26 form" do + let(:start_date) { Time.utc(2025, 4, 1) } + + before do + allow(page.subsection.form).to receive(:start_year_2024_or_later?).and_return(true) + end + + it "has the correct question number" do + expect(question.question_number).to eq(29) + end + end end diff --git a/spec/models/form/lettings/questions/tenancy_length_spec.rb b/spec/models/form/lettings/questions/tenancy_length_spec.rb index cc7bf9f9f..3046c290f 100644 --- a/spec/models/form/lettings/questions/tenancy_length_spec.rb +++ b/spec/models/form/lettings/questions/tenancy_length_spec.rb @@ -3,7 +3,8 @@ require "rails_helper" RSpec.describe Form::Lettings::Questions::TenancyLength, type: :model do subject(:question) { described_class.new(nil, nil, page) } - let(:page) { instance_double(Form::Page, subsection: instance_double(Form::Subsection, form: instance_double(Form, start_date: Time.zone.local(2023, 4, 1))), id: "tenancy_length") } + let(:page) { instance_double(Form::Page, subsection: instance_double(Form::Subsection, form: instance_double(Form, start_date:)), id: "tenancy_length") } + let(:start_date) { Time.utc(2023, 4, 1) } it "has correct page" do expect(question.page).to eq(page) @@ -29,4 +30,28 @@ RSpec.describe Form::Lettings::Questions::TenancyLength, type: :model do it "is not marked as derived" do expect(question.derived?(nil)).to be false end + + context "with 2024/25 form" do + let(:start_date) { Time.utc(2024, 4, 1) } + + before do + allow(page.subsection.form).to receive(:start_year_2024_or_later?).and_return(true) + end + + it "has the correct question number" do + expect(question.question_number).to eq(28) + end + end + + context "with 2025/26 form" do + let(:start_date) { Time.utc(2025, 4, 1) } + + before do + allow(page.subsection.form).to receive(:start_year_2024_or_later?).and_return(true) + end + + it "has the correct question number" do + expect(question.question_number).to eq(29) + end + end end diff --git a/spec/models/form/lettings/questions/tenancy_other_spec.rb b/spec/models/form/lettings/questions/tenancy_other_spec.rb index a6a2962dc..38bd87d05 100644 --- a/spec/models/form/lettings/questions/tenancy_other_spec.rb +++ b/spec/models/form/lettings/questions/tenancy_other_spec.rb @@ -3,7 +3,8 @@ require "rails_helper" RSpec.describe Form::Lettings::Questions::TenancyOther, type: :model do subject(:question) { described_class.new(nil, nil, page) } - let(:page) { instance_double(Form::Page, subsection: instance_double(Form::Subsection, form: instance_double(Form, start_date: Time.zone.local(2023, 4, 1))), id: "tenancy_type") } + let(:page) { instance_double(Form::Page, subsection: instance_double(Form::Subsection, form: instance_double(Form, start_date:)), id: "tenancy_type") } + let(:start_date) { Time.utc(2023, 4, 1) } it "has correct page" do expect(question.page).to eq(page) @@ -20,4 +21,28 @@ RSpec.describe Form::Lettings::Questions::TenancyOther, type: :model do it "is not marked as derived" do expect(question.derived?(nil)).to be false end + + context "with 2024/25 form" do + let(:start_date) { Time.utc(2024, 4, 1) } + + before do + allow(page.subsection.form).to receive(:start_year_2024_or_later?).and_return(true) + end + + it "has the correct question number" do + expect(question.question_number).to eq(27) + end + end + + context "with 2025/26 form" do + let(:start_date) { Time.utc(2025, 4, 1) } + + before do + allow(page.subsection.form).to receive(:start_year_2024_or_later?).and_return(true) + end + + it "has the correct question number" do + expect(question.question_number).to eq(28) + end + end end diff --git a/spec/models/form/lettings/questions/tenancy_type_spec.rb b/spec/models/form/lettings/questions/tenancy_type_spec.rb index 82a5ae3e7..13cb5bb77 100644 --- a/spec/models/form/lettings/questions/tenancy_type_spec.rb +++ b/spec/models/form/lettings/questions/tenancy_type_spec.rb @@ -5,7 +5,8 @@ RSpec.describe Form::Lettings::Questions::TenancyType, type: :model do let(:page) { instance_double(Form::Page, id: "tenancy_type") } let(:subsection) { instance_double(Form::Subsection) } - let(:form) { instance_double(Form, start_date: Time.zone.local(2023, 4, 1)) } + let(:form) { instance_double(Form, start_date:) } + let(:start_date) { Time.utc(2023, 4, 1) } before do allow(form).to receive(:start_year_2024_or_later?).and_return(false) @@ -64,6 +65,8 @@ RSpec.describe Form::Lettings::Questions::TenancyType, type: :model do end context "with 2024/25 form" do + let(:start_date) { Time.utc(2024, 4, 1) } + before do allow(form).to receive(:start_year_2024_or_later?).and_return(true) end @@ -99,6 +102,22 @@ RSpec.describe Form::Lettings::Questions::TenancyType, type: :model do }, ) end + + it "has the correct question number" do + expect(question.question_number).to eq(27) + end + end + + context "with 2025/26 form" do + let(:start_date) { Time.utc(2025, 4, 1) } + + before do + allow(form).to receive(:start_year_2024_or_later?).and_return(true) + end + + it "has the correct question number" do + expect(question.question_number).to eq(28) + end end it "is not marked as derived" do