Browse Source

Add some question number tests

pull/2953/head
Manny Dinssa 2 months ago
parent
commit
4ff944a6a1
  1. 18
      spec/models/form/lettings/questions/first_time_property_let_as_social_housing_spec.rb
  2. 24
      spec/models/form/lettings/questions/joint_spec.rb
  3. 24
      spec/models/form/lettings/questions/la_spec.rb
  4. 12
      spec/models/form/lettings/questions/previous_let_type_spec.rb
  5. 24
      spec/models/form/lettings/questions/rsnvac_spec.rb
  6. 12
      spec/models/form/lettings/questions/sheltered_spec.rb
  7. 18
      spec/models/form/lettings/questions/starter_tenancy_type_spec.rb
  8. 27
      spec/models/form/lettings/questions/tenancy_length_affordable_rent_spec.rb
  9. 27
      spec/models/form/lettings/questions/tenancy_length_intermediate_rent_spec.rb
  10. 27
      spec/models/form/lettings/questions/tenancy_length_periodic_spec.rb
  11. 27
      spec/models/form/lettings/questions/tenancy_length_spec.rb
  12. 27
      spec/models/form/lettings/questions/tenancy_other_spec.rb
  13. 21
      spec/models/form/lettings/questions/tenancy_type_spec.rb

18
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 end
context "with 2024/25 form" do context "with 2024/25 form" do
let(:form) { instance_double(Form, start_date: Time.zone.local(2024, 4, 1)) }
before do before do
allow(form).to receive(:start_year_2024_or_later?).and_return(true) allow(form).to receive(:start_year_2024_or_later?).and_return(true)
end 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." }, "0" => { "value" => "No", "hint" => "This is a re-let of existing social housing stock." },
}) })
end 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
end end

24
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 it "is not marked as derived" do
expect(question.derived?(nil)).to be false expect(question.derived?(nil)).to be false
end 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 end

24
spec/models/form/lettings/questions/la_spec.rb

@ -310,4 +310,28 @@ RSpec.describe Form::Lettings::Questions::La, type: :model do
"E06000065" => "North Yorkshire", "E06000065" => "North Yorkshire",
}) })
end 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 end

12
spec/models/form/lettings/questions/previous_let_type_spec.rb

@ -44,6 +44,8 @@ RSpec.describe Form::Lettings::Questions::PreviousLetType, type: :model do
end end
context "with collection year on or after 2024" do context "with collection year on or after 2024" do
let(:form) { instance_double(Form, start_date: Time.zone.local(2024, 4, 1)) }
before do before do
allow(form).to receive(:start_year_2024_or_later?).and_return(true) allow(form).to receive(:start_year_2024_or_later?).and_return(true)
end end
@ -60,9 +62,15 @@ RSpec.describe Form::Lettings::Questions::PreviousLetType, type: :model do
"3" => { "value" => "Don’t know" }, "3" => { "value" => "Don’t know" },
}) })
end end
it "has the correct question number" do
expect(question.question_number).to eq(17)
end
end end
context "with collection year on or after 2025" do context "with collection year on or after 2025" do
let(:form) { instance_double(Form, start_date: Time.zone.local(2025, 4, 1)) }
before do before do
allow(form).to receive(:start_year_2025_or_later?).and_return(true) allow(form).to receive(:start_year_2025_or_later?).and_return(true)
end end
@ -80,5 +88,9 @@ RSpec.describe Form::Lettings::Questions::PreviousLetType, type: :model do
"3" => { "value" => "Don’t know" }, "3" => { "value" => "Don’t know" },
}) })
end end
it "has the correct question number" do
expect(question.question_number).to eq(14)
end
end end
end end

24
spec/models/form/lettings/questions/rsnvac_spec.rb

@ -76,7 +76,13 @@ RSpec.describe Form::Lettings::Questions::Rsnvac, type: :model do
end end
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 context "with 2024/25 form" do
let(:form) { instance_double(Form, start_date: Time.zone.local(2024, 4, 1)) }
before do before do
allow(form).to receive(:start_year_2024_or_later?).and_return(true) allow(form).to receive(:start_year_2024_or_later?).and_return(true)
end end
@ -129,9 +135,23 @@ RSpec.describe Form::Lettings::Questions::Rsnvac, type: :model do
}, },
}) })
end end
it "has the correct question number" do
expect(question.question_number).to eq(18)
end
end end
it "has the correct check_answers_card_number" do context "with 2025/26 form" do
expect(question.check_answers_card_number).to eq(0) 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
end end

12
spec/models/form/lettings/questions/sheltered_spec.rb

@ -26,6 +26,8 @@ RSpec.describe Form::Lettings::Questions::Sheltered, type: :model do
end end
context "with 2024/25 form" do context "with 2024/25 form" do
let(:form) { instance_double(Form, start_date: Time.zone.local(2024, 4, 1)) }
before do before do
allow(form).to receive(:start_year_2024_or_later?).and_return(true) allow(form).to receive(:start_year_2024_or_later?).and_return(true)
allow(form).to receive(:start_year_2025_or_later?).and_return(false) 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" }, "4" => { "value" => "Don’t know" },
}) })
end end
it "has the correct question number" do
expect(question.question_number).to eq(29)
end
end end
context "with 2025/26 form" do context "with 2025/26 form" do
let(:form) { instance_double(Form, start_date: Time.zone.local(2025, 4, 1)) }
before do before do
allow(form).to receive(:start_year_2024_or_later?).and_return(true) 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_2025_or_later?).and_return(true)
@ -60,6 +68,10 @@ RSpec.describe Form::Lettings::Questions::Sheltered, type: :model do
"4" => { "value" => "Don’t know" }, "4" => { "value" => "Don’t know" },
}) })
end end
it "has the correct question number" do
expect(question.question_number).to eq(25)
end
end end
it "is not marked as derived" do it "is not marked as derived" do

18
spec/models/form/lettings/questions/starter_tenancy_type_spec.rb

@ -49,6 +49,8 @@ RSpec.describe Form::Lettings::Questions::StarterTenancyType, type: :model do
end end
context "with 2024/25 form" do context "with 2024/25 form" do
let(:form) { instance_double(Form, start_date: Time.zone.local(2024, 4, 1)) }
before do before do
allow(form).to receive(:start_year_2024_or_later?).and_return(true) allow(form).to receive(:start_year_2024_or_later?).and_return(true)
end end
@ -84,5 +86,21 @@ RSpec.describe Form::Lettings::Questions::StarterTenancyType, type: :model do
}, },
) )
end 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
end end

27
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(:question_definition) { nil }
let(:page) { instance_double(Form::Page, id: "affordable_tenancy_length") } let(:page) { instance_double(Form::Page, id: "affordable_tenancy_length") }
let(:subsection) { instance_double(Form::Subsection) } 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 before do
allow(form).to receive(:start_year_2024_or_later?).and_return(false) 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 it "has the correct type" do
expect(question.type).to eq("numeric") expect(question.type).to eq("numeric")
end 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 end

27
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(:question_definition) { nil }
let(:page) { instance_double(Form::Page, id: "intermediate_tenancy_length") } let(:page) { instance_double(Form::Page, id: "intermediate_tenancy_length") }
let(:subsection) { instance_double(Form::Subsection) } 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 before do
allow(form).to receive(:start_year_2024_or_later?).and_return(false) 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 it "has the correct type" do
expect(question.type).to eq("numeric") expect(question.type).to eq("numeric")
end 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 end

27
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_id) { nil }
let(:question_definition) { 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 it "has correct page" do
expect(question.page).to eq(page) 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 it "has the correct type" do
expect(question.type).to eq("numeric") expect(question.type).to eq("numeric")
end 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 end

27
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 RSpec.describe Form::Lettings::Questions::TenancyLength, type: :model do
subject(:question) { described_class.new(nil, nil, page) } 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 it "has correct page" do
expect(question.page).to eq(page) 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 it "is not marked as derived" do
expect(question.derived?(nil)).to be false expect(question.derived?(nil)).to be false
end 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 end

27
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 RSpec.describe Form::Lettings::Questions::TenancyOther, type: :model do
subject(:question) { described_class.new(nil, nil, page) } 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 it "has correct page" do
expect(question.page).to eq(page) 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 it "is not marked as derived" do
expect(question.derived?(nil)).to be false expect(question.derived?(nil)).to be false
end 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 end

21
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(:page) { instance_double(Form::Page, id: "tenancy_type") }
let(:subsection) { instance_double(Form::Subsection) } 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 before do
allow(form).to receive(:start_year_2024_or_later?).and_return(false) 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 end
context "with 2024/25 form" do context "with 2024/25 form" do
let(:start_date) { Time.utc(2024, 4, 1) }
before do before do
allow(form).to receive(:start_year_2024_or_later?).and_return(true) allow(form).to receive(:start_year_2024_or_later?).and_return(true)
end end
@ -99,6 +102,22 @@ RSpec.describe Form::Lettings::Questions::TenancyType, type: :model do
}, },
) )
end 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 end
it "is not marked as derived" do it "is not marked as derived" do

Loading…
Cancel
Save