Browse Source

CLDC-4402: bump loads of tests up from 2023

CLDC-4402-audit-start-year-2024-or-later-usage-2
Rebecca Jesson 4 days ago
parent
commit
76710eab2f
  1. 5
      spec/models/form/lettings/pages/first_time_property_let_as_social_housing_spec.rb
  2. 5
      spec/models/form/lettings/pages/lead_tenant_ethnic_background_white_spec.rb
  3. 4
      spec/models/form/lettings/pages/person_age_spec.rb
  4. 4
      spec/models/form/lettings/pages/person_relationship_to_lead_spec.rb
  5. 4
      spec/models/form/lettings/pages/previous_local_authority_spec.rb
  6. 4
      spec/models/form/lettings/pages/previous_postcode_spec.rb
  7. 8
      spec/models/form/lettings/pages/property_wheelchair_accessible_spec.rb
  8. 7
      spec/models/form/lettings/pages/renewal_spec.rb
  9. 6
      spec/models/form/lettings/pages/rent_type_spec.rb
  10. 5
      spec/models/form/lettings/pages/starter_tenancy_type_spec.rb
  11. 35
      spec/models/form/lettings/pages/uprn_spec.rb
  12. 6
      spec/models/form/lettings/questions/address_line1_spec.rb
  13. 12
      spec/models/form/lettings/questions/address_search_spec.rb
  14. 5
      spec/models/form/lettings/questions/age1_known_spec.rb
  15. 2
      spec/models/form/lettings/questions/age_spec.rb
  16. 4
      spec/models/form/lettings/questions/gender_identity1_spec.rb
  17. 5
      spec/models/form/lettings/questions/hb_spec.rb
  18. 13
      spec/models/form/lettings/questions/joint_spec.rb
  19. 613
      spec/models/form/lettings/questions/la_spec.rb
  20. 5
      spec/models/form/lettings/questions/ppcodenk_spec.rb
  21. 5
      spec/models/form/lettings/questions/previous_la_known_spec.rb
  22. 11
      spec/models/form/lettings/questions/reason_spec.rb
  23. 5
      spec/models/form/lettings/questions/reasonpref_spec.rb
  24. 5
      spec/models/form/lettings/questions/renewal_spec.rb
  25. 5
      spec/models/form/lettings/questions/scheme_id_spec.rb
  26. 9
      spec/models/form/lettings/questions/sheltered_spec.rb
  27. 13
      spec/models/form/lettings/questions/tenancy_length_affordable_rent_spec.rb
  28. 13
      spec/models/form/lettings/questions/tenancy_length_intermediate_rent_spec.rb
  29. 12
      spec/models/form/lettings/questions/tenancy_length_periodic_spec.rb
  30. 12
      spec/models/form/lettings/questions/tenancy_length_spec.rb
  31. 12
      spec/models/form/lettings/questions/tenancy_other_spec.rb
  32. 4
      spec/models/form/lettings/questions/wheelchair_spec.rb
  33. 11
      spec/models/form/lettings/subsections/household_characteristics_spec.rb
  34. 11
      spec/models/form/lettings/subsections/household_situation_spec.rb
  35. 4
      spec/models/form/sales/pages/buyer1_ethnic_background_arab_spec.rb
  36. 4
      spec/models/form/sales/pages/buyer1_ethnic_background_asian_spec.rb
  37. 4
      spec/models/form/sales/pages/buyer1_ethnic_background_black_spec.rb
  38. 4
      spec/models/form/sales/pages/buyer1_ethnic_background_mixed_spec.rb
  39. 5
      spec/models/form/sales/pages/buyer1_ethnic_background_white_spec.rb
  40. 4
      spec/models/form/sales/pages/buyer1_ethnic_group_spec.rb
  41. 4
      spec/models/form/sales/pages/buyer1_live_in_property_spec.rb
  42. 4
      spec/models/form/sales/pages/buyer1_working_situation_spec.rb
  43. 4
      spec/models/form/sales/pages/buyer2_ethnic_group_spec.rb
  44. 4
      spec/models/form/sales/pages/buyer2_live_in_property_spec.rb
  45. 4
      spec/models/form/sales/pages/buyer2_relationship_to_buyer1_spec.rb
  46. 4
      spec/models/form/sales/pages/buyer2_working_situation_spec.rb
  47. 4
      spec/models/form/sales/pages/buyer_interview_spec.rb
  48. 4
      spec/models/form/sales/pages/buyer_live_spec.rb
  49. 4
      spec/models/form/sales/pages/discount_spec.rb
  50. 4
      spec/models/form/sales/pages/joint_purchase_spec.rb
  51. 4
      spec/models/form/sales/pages/person_relationship_to_buyer1_spec.rb
  52. 4
      spec/models/form/sales/pages/privacy_notice_spec.rb
  53. 2
      spec/models/form/sales/pages/property_wheelchair_accessible_spec.rb
  54. 4
      spec/models/form/sales/pages/purchase_price_spec.rb
  55. 2
      spec/models/form/sales/pages/shared_ownership_type_spec.rb
  56. 35
      spec/models/form/sales/pages/uprn_spec.rb
  57. 4
      spec/models/form/sales/questions/buyer1_ethnic_background_arab_spec.rb
  58. 4
      spec/models/form/sales/questions/buyer1_ethnic_background_asian_spec.rb
  59. 4
      spec/models/form/sales/questions/buyer1_ethnic_background_black_spec.rb
  60. 4
      spec/models/form/sales/questions/buyer1_ethnic_background_mixed_spec.rb
  61. 4
      spec/models/form/sales/questions/buyer1_ethnic_group_spec.rb
  62. 4
      spec/models/form/sales/questions/buyer1_live_in_property_spec.rb
  63. 4
      spec/models/form/sales/questions/buyer_interview_spec.rb
  64. 1
      spec/models/form/sales/questions/buyer_live_spec.rb
  65. 3
      spec/models/form/sales/questions/mortgageused_spec.rb
  66. 62
      spec/models/form/sales/questions/nationality_all_group_spec.rb
  67. 4
      spec/models/form/sales/questions/number_joint_buyers_spec.rb
  68. 4
      spec/models/form/sales/questions/person_age_spec.rb
  69. 4
      spec/models/form/sales/questions/property_wheelchair_accessible_spec.rb
  70. 12
      spec/models/form/sales/questions/shared_ownership_type_spec.rb
  71. 6
      spec/models/form/sales/subsections/household_situation_spec.rb

5
spec/models/form/lettings/pages/first_time_property_let_as_social_housing_spec.rb

@ -1,15 +1,16 @@
require "rails_helper"
RSpec.describe Form::Lettings::Pages::FirstTimePropertyLetAsSocialHousing, type: :model do
include CollectionTimeHelper
subject(:page) { described_class.new(page_id, page_definition, subsection) }
let(:page_id) { nil }
let(:page_definition) { nil }
let(:subsection) { instance_double(Form::Subsection) }
let(:form) { instance_double(Form, start_date: Time.zone.local(2024, 4, 1)) }
let(:form) { instance_double(Form, start_date: current_collection_start_date) }
before do
allow(form).to receive(:start_year_2024_or_later?).and_return(false)
allow(subsection).to receive(:form).and_return(form)
end

5
spec/models/form/lettings/pages/lead_tenant_ethnic_background_white_spec.rb

@ -1,15 +1,16 @@
require "rails_helper"
RSpec.describe Form::Lettings::Pages::LeadTenantEthnicBackgroundWhite, type: :model do
include CollectionTimeHelper
subject(:page) { described_class.new(page_id, page_definition, subsection) }
let(:page_id) { nil }
let(:page_definition) { nil }
let(:subsection) { instance_double(Form::Subsection) }
let(:form) { instance_double(Form, start_date: Time.zone.local(2024, 4, 1)) }
let(:form) { instance_double(Form, start_date: current_collection_start_date) }
before do
allow(form).to receive(:start_year_2024_or_later?).and_return(false)
allow(subsection).to receive(:form).and_return(form)
end

4
spec/models/form/lettings/pages/person_age_spec.rb

@ -1,10 +1,12 @@
require "rails_helper"
RSpec.describe Form::Lettings::Pages::PersonAge, type: :model do
include CollectionTimeHelper
subject(:page) { described_class.new(nil, page_definition, subsection, person_index:) }
let(:page_definition) { nil }
let(:subsection) { instance_double(Form::Subsection, form: instance_double(Form, start_date: Time.zone.local(2024, 4, 1), start_year_2024_or_later?: false, start_year_2026_or_later?: false, person_question_count: 4)) }
let(:subsection) { instance_double(Form::Subsection, form: instance_double(Form, start_date: current_collection_start_date, start_year_2026_or_later?: false, person_question_count: 4)) }
let(:person_index) { 2 }
it "has correct subsection" do

4
spec/models/form/lettings/pages/person_relationship_to_lead_spec.rb

@ -1,10 +1,12 @@
require "rails_helper"
RSpec.describe Form::Lettings::Pages::PersonRelationshipToLead, type: :model do
include CollectionTimeHelper
subject(:page) { described_class.new(nil, page_definition, subsection, person_index:) }
let(:page_definition) { nil }
let(:subsection) { instance_double(Form::Subsection, form: instance_double(Form, start_date: Time.zone.local(2024, 4, 1), start_year_2024_or_later?: false)) }
let(:subsection) { instance_double(Form::Subsection, form: instance_double(Form, start_date: current_collection_start_date)) }
let(:person_index) { 2 }
it "has correct subsection" do

4
spec/models/form/lettings/pages/previous_local_authority_spec.rb

@ -1,11 +1,13 @@
require "rails_helper"
RSpec.describe Form::Lettings::Pages::PreviousLocalAuthority, type: :model do
include CollectionTimeHelper
subject(:page) { described_class.new(page_id, page_definition, subsection) }
let(:page_id) { nil }
let(:page_definition) { nil }
let(:subsection) { instance_double(Form::Subsection, form: instance_double(Form, start_year_2024_or_later?: false, start_date: Time.zone.local(2023, 4, 1))) }
let(:subsection) { instance_double(Form::Subsection, form: instance_double(Form, start_date: current_collection_start_date)) }
it "has correct subsection" do
expect(page.subsection).to eq(subsection)

4
spec/models/form/lettings/pages/previous_postcode_spec.rb

@ -1,11 +1,13 @@
require "rails_helper"
RSpec.describe Form::Lettings::Pages::PreviousPostcode, type: :model do
include CollectionTimeHelper
subject(:page) { described_class.new(page_id, page_definition, subsection) }
let(:page_id) { "previous_postcode" }
let(:page_definition) { nil }
let(:subsection) { instance_double(Form::Subsection, form: instance_double(Form, start_year_2024_or_later?: false, start_date: Time.zone.local(2023, 4, 1))) }
let(:subsection) { instance_double(Form::Subsection, form: instance_double(Form, start_date: current_collection_start_date)) }
it "has correct subsection" do
expect(page.subsection).to eq(subsection)

8
spec/models/form/lettings/pages/property_wheelchair_accessible_spec.rb

@ -1,13 +1,11 @@
require "rails_helper"
RSpec.describe Form::Lettings::Pages::PropertyWheelchairAccessible, type: :model do
subject(:page) { described_class.new(nil, nil, subsection) }
include CollectionTimeHelper
let(:subsection) { instance_double(Form::Subsection, form: instance_double(Form, start_date: Time.zone.local(2024, 4, 1))) }
subject(:page) { described_class.new(nil, nil, subsection) }
before do
allow(subsection).to receive(:form).and_return(instance_double(Form, start_year_2024_or_later?: false, start_date: Time.zone.local(2023, 4, 1)))
end
let(:subsection) { instance_double(Form::Subsection, form: instance_double(Form, start_date: current_collection_start_date)) }
it "has correct subsection" do
expect(page.subsection).to be(subsection)

7
spec/models/form/lettings/pages/renewal_spec.rb

@ -1,15 +1,16 @@
require "rails_helper"
RSpec.describe Form::Lettings::Pages::Renewal, type: :model do
include CollectionTimeHelper
subject(:page) { described_class.new(page_id, page_definition, subsection) }
let(:page_id) { nil }
let(:page_definition) { nil }
let(:subsection) { instance_double(Form::Subsection, form: instance_double(Form, start_date: Time.zone.local(2024, 4, 1))) }
let(:form) { instance_double(Form, start_date: Time.zone.local(2024, 4, 1)) }
let(:subsection) { instance_double(Form::Subsection, form: instance_double(Form, start_date: current_collection_start_date)) }
let(:form) { instance_double(Form, start_date: current_collection_start_date) }
before do
allow(form).to receive(:start_year_2024_or_later?).and_return(false)
allow(subsection).to receive(:form).and_return(form)
end

6
spec/models/form/lettings/pages/rent_type_spec.rb

@ -1,16 +1,18 @@
require "rails_helper"
RSpec.describe Form::Lettings::Pages::RentType, type: :model do
include CollectionTimeHelper
subject(:page) { described_class.new(page_id, page_definition, subsection) }
let(:page_id) { nil }
let(:page_definition) { nil }
let(:subsection) { instance_double(Form::Subsection) }
let(:form) { instance_double(Form, start_date: Time.zone.local(2024, 4, 1)) }
let(:form) { instance_double(Form, start_date: current_collection_start_date) }
before do
allow(subsection).to receive(:form).and_return(form)
allow(form).to receive_messages(start_year_2024_or_later?: true, start_year_2025_or_later?: false)
allow(form).to receive_messages(start_year_2025_or_later?: false)
end
it "has correct subsection" do

5
spec/models/form/lettings/pages/starter_tenancy_type_spec.rb

@ -1,13 +1,14 @@
require "rails_helper"
RSpec.describe Form::Lettings::Pages::StarterTenancyType, type: :model do
include CollectionTimeHelper
subject(:page) { described_class.new(nil, nil, subsection) }
let(:subsection) { instance_double(Form::Subsection) }
let(:form) { instance_double(Form, start_date: Time.zone.local(2024, 4, 1)) }
let(:form) { instance_double(Form, start_date: current_collection_start_date) }
before do
allow(form).to receive(:start_year_2024_or_later?).and_return(false)
allow(subsection).to receive(:form).and_return(form)
end

35
spec/models/form/lettings/pages/uprn_spec.rb

@ -1,15 +1,16 @@
require "rails_helper"
RSpec.describe Form::Lettings::Pages::Uprn, type: :model do
include CollectionTimeHelper
subject(:page) { described_class.new(page_id, page_definition, subsection) }
let(:page_id) { nil }
let(:page_definition) { nil }
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: current_collection_start_date) }
before do
allow(form).to receive(:start_year_2024_or_later?).and_return(false)
allow(subsection).to receive(:form).and_return(form)
end
@ -43,32 +44,14 @@ RSpec.describe Form::Lettings::Pages::Uprn, type: :model do
context "when log is present" do
let(:log) { build(:lettings_log) }
context "with 2023/24 form" do
it "points to address page" do
expect(page.skip_href(log)).to eq(
"address",
)
end
it "has correct skip_text" do
expect(page.skip_text).to eq("Enter address instead")
end
it "points to address search page" do
expect(page.skip_href(log)).to eq(
"address-matcher",
)
end
context "with 2024/25 form" do
before do
allow(form).to receive(:start_year_2024_or_later?).and_return(true)
end
it "points to address search page" do
expect(page.skip_href(log)).to eq(
"address-matcher",
)
end
it "has correct skip_text" do
expect(page.skip_text).to eq("Search for address instead")
end
it "has correct skip_text" do
expect(page.skip_text).to eq("Search for address instead")
end
end
end

6
spec/models/form/lettings/questions/address_line1_spec.rb

@ -1,11 +1,13 @@
require "rails_helper"
RSpec.describe Form::Lettings::Questions::AddressLine1, type: :model do
include CollectionTimeHelper
subject(:question) { described_class.new(question_id, question_definition, page) }
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)))) }
let(:page) { instance_double(Form::Page, subsection: instance_double(Form::Subsection, form: instance_double(Form, start_date: current_collection_start_date))) }
it "has correct page" do
expect(question.page).to eq(page)
@ -20,7 +22,7 @@ RSpec.describe Form::Lettings::Questions::AddressLine1, type: :model do
end
it "has the correct question_number" do
expect(question.question_number).to eq(12)
expect(question.question_number).to eq(17)
end
it "has the correct type" do

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

@ -1,12 +1,14 @@
require "rails_helper"
RSpec.describe Form::Lettings::Questions::AddressSearch, type: :model do
include CollectionTimeHelper
subject(:question) { described_class.new(question_id, question_definition, page) }
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:))) }
let(:start_date) { Time.utc(2024, 4, 1) }
let(:start_date) { current_collection_start_date }
it "has correct page" do
expect(question.page).to eq(page)
@ -20,8 +22,12 @@ RSpec.describe Form::Lettings::Questions::AddressSearch, type: :model do
expect(question.type).to eq("address_search")
end
it "has the correct question number" do
expect(question.question_number).to eq(12)
context "with 2024/25 form" do
let(:start_date) { Time.utc(2024, 4, 1) }
it "has the correct question number" do
expect(question.question_number).to eq(12)
end
end
context "with 2025/26 form" do

5
spec/models/form/lettings/questions/age1_known_spec.rb

@ -1,15 +1,16 @@
require "rails_helper"
RSpec.describe Form::Lettings::Questions::Age1Known, type: :model do
include CollectionTimeHelper
subject(:question) { described_class.new(nil, question_definition, page) }
let(:question_definition) { nil }
let(:page) { instance_double(Form::Page) }
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: current_collection_start_date) }
before do
allow(form).to receive(:start_year_2024_or_later?).and_return(false)
allow(page).to receive(:subsection).and_return(subsection)
allow(subsection).to receive(:form).and_return(form)
end

2
spec/models/form/lettings/questions/age_spec.rb

@ -9,7 +9,7 @@ RSpec.describe Form::Lettings::Questions::Age, type: :model do
let(:start_year_2026_or_later?) { false }
let(:person_question_count) { 5 }
let(:start_year) { current_collection_start_year }
let(:page) { instance_double(Form::Page, subsection: instance_double(Form::Subsection, form: instance_double(Form, start_date: collection_start_date_for_year(start_year), start_year_2024_or_later?: true, start_year_2026_or_later?: start_year_2026_or_later?, person_question_count:))) }
let(:page) { instance_double(Form::Page, subsection: instance_double(Form::Subsection, form: instance_double(Form, start_date: collection_start_date_for_year(start_year), start_year_2026_or_later?: start_year_2026_or_later?, person_question_count:))) }
let(:person_index) { 2 }
it "has correct page" do

4
spec/models/form/lettings/questions/gender_identity1_spec.rb

@ -1,12 +1,14 @@
require "rails_helper"
RSpec.describe Form::Lettings::Questions::GenderIdentity1, type: :model do
include CollectionTimeHelper
subject(:question) { described_class.new(nil, question_definition, page) }
let(:question_definition) { nil }
let(:page) { instance_double(Form::Page) }
let(:subsection) { instance_double(Form::Subsection) }
let(:form) { instance_double(Form, start_date: Time.zone.local(2023, 4, 1), start_year_2024_or_later?: false) }
let(:form) { instance_double(Form, start_date: current_collection_start_date) }
before do
allow(page).to receive(:subsection).and_return(subsection)

5
spec/models/form/lettings/questions/hb_spec.rb

@ -1,16 +1,17 @@
require "rails_helper"
RSpec.describe Form::Lettings::Questions::Hb, type: :model do
include CollectionTimeHelper
subject(:question) { described_class.new(question_id, question_definition, page) }
let(:question_id) { nil }
let(:question_definition) { nil }
let(:page) { instance_double(Form::Page) }
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: current_collection_start_date) }
before do
allow(form).to receive(:start_year_2024_or_later?).and_return(false)
allow(page).to receive(:subsection).and_return(subsection)
allow(subsection).to receive(:form).and_return(form)
end

13
spec/models/form/lettings/questions/joint_spec.rb

@ -1,16 +1,17 @@
require "rails_helper"
RSpec.describe Form::Lettings::Questions::Joint, type: :model do
include CollectionTimeHelper
subject(:question) { described_class.new(question_id, question_definition, page) }
let(:question_id) { nil }
let(:question_definition) { nil }
let(:page) { instance_double(Form::Page) }
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: current_collection_start_date) }
before do
allow(form).to receive(:start_year_2024_or_later?).and_return(false)
allow(page).to receive(:subsection).and_return(subsection)
allow(subsection).to receive(:form).and_return(form)
end
@ -43,10 +44,6 @@ RSpec.describe Form::Lettings::Questions::Joint, type: :model do
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
@ -55,10 +52,6 @@ RSpec.describe Form::Lettings::Questions::Joint, type: :model do
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

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

@ -7,317 +7,316 @@ RSpec.describe Form::Lettings::Questions::La, type: :model do
let(:question_definition) { nil }
let(:subsection) { instance_double(Form::Subsection, form: instance_double(Form, start_date:)) }
let(:page) { instance_double(Form::Page, subsection:) }
let(:start_date) { Time.utc(2023, 4, 1) }
it "has the correct answer_options" do
expect(question.answer_options).to eq({
"" => "Select an option",
"E06000001" => "Hartlepool",
"E06000002" => "Middlesbrough",
"E06000003" => "Redcar and Cleveland",
"E06000004" => "Stockton-on-Tees",
"E06000005" => "Darlington",
"E06000006" => "Halton",
"E06000007" => "Warrington",
"E06000008" => "Blackburn with Darwen",
"E06000009" => "Blackpool",
"E06000010" => "Kingston upon Hull, City of",
"E06000011" => "East Riding of Yorkshire",
"E06000012" => "North East Lincolnshire",
"E06000013" => "North Lincolnshire",
"E06000014" => "York",
"E06000015" => "Derby",
"E06000016" => "Leicester",
"E06000017" => "Rutland",
"E06000018" => "Nottingham",
"E06000019" => "Herefordshire, County of",
"E06000020" => "Telford and Wrekin",
"E06000021" => "Stoke-on-Trent",
"E06000022" => "Bath and North East Somerset",
"E06000023" => "Bristol, City of",
"E06000024" => "North Somerset",
"E06000025" => "South Gloucestershire",
"E06000026" => "Plymouth",
"E06000027" => "Torbay",
"E06000030" => "Swindon",
"E06000031" => "Peterborough",
"E06000032" => "Luton",
"E06000033" => "Southend-on-Sea",
"E06000034" => "Thurrock",
"E06000035" => "Medway",
"E06000036" => "Bracknell Forest",
"E06000037" => "West Berkshire",
"E06000038" => "Reading",
"E06000039" => "Slough",
"E06000040" => "Windsor and Maidenhead",
"E06000041" => "Wokingham",
"E06000042" => "Milton Keynes",
"E06000043" => "Brighton and Hove",
"E06000044" => "Portsmouth",
"E06000045" => "Southampton",
"E06000046" => "Isle of Wight",
"E06000047" => "County Durham",
"E06000049" => "Cheshire East",
"E06000050" => "Cheshire West and Chester",
"E06000051" => "Shropshire",
"E06000052" => "Cornwall",
"E06000053" => "Isles of Scilly",
"E06000054" => "Wiltshire",
"E06000055" => "Bedford",
"E06000056" => "Central Bedfordshire",
"E06000057" => "Northumberland",
"E06000058" => "Bournemouth, Christchurch and Poole",
"E06000059" => "Dorset",
"E06000060" => "Buckinghamshire",
"E07000008" => "Cambridge",
"E07000009" => "East Cambridgeshire",
"E07000010" => "Fenland",
"E07000011" => "Huntingdonshire",
"E07000012" => "South Cambridgeshire",
"E07000032" => "Amber Valley",
"E07000033" => "Bolsover",
"E07000034" => "Chesterfield",
"E07000035" => "Derbyshire Dales",
"E07000036" => "Erewash",
"E07000037" => "High Peak",
"E07000038" => "North East Derbyshire",
"E07000039" => "South Derbyshire",
"E07000040" => "East Devon",
"E07000041" => "Exeter",
"E07000042" => "Mid Devon",
"E07000043" => "North Devon",
"E07000044" => "South Hams",
"E07000045" => "Teignbridge",
"E07000046" => "Torridge",
"E07000047" => "West Devon",
"E07000061" => "Eastbourne",
"E07000062" => "Hastings",
"E07000063" => "Lewes",
"E07000064" => "Rother",
"E07000065" => "Wealden",
"E07000066" => "Basildon",
"E07000067" => "Braintree",
"E07000068" => "Brentwood",
"E07000069" => "Castle Point",
"E07000070" => "Chelmsford",
"E07000071" => "Colchester",
"E07000072" => "Epping Forest",
"E07000073" => "Harlow",
"E07000074" => "Maldon",
"E07000075" => "Rochford",
"E07000076" => "Tendring",
"E07000077" => "Uttlesford",
"E07000078" => "Cheltenham",
"E07000079" => "Cotswold",
"E07000080" => "Forest of Dean",
"E07000081" => "Gloucester",
"E07000082" => "Stroud",
"E07000083" => "Tewkesbury",
"E07000084" => "Basingstoke and Deane",
"E07000085" => "East Hampshire",
"E07000086" => "Eastleigh",
"E07000087" => "Fareham",
"E07000088" => "Gosport",
"E07000089" => "Hart",
"E07000090" => "Havant",
"E07000091" => "New Forest",
"E07000092" => "Rushmoor",
"E07000093" => "Test Valley",
"E07000094" => "Winchester",
"E07000095" => "Broxbourne",
"E07000096" => "Dacorum",
"E07000098" => "Hertsmere",
"E07000099" => "North Hertfordshire",
"E07000102" => "Three Rivers",
"E07000103" => "Watford",
"E07000105" => "Ashford",
"E07000106" => "Canterbury",
"E07000107" => "Dartford",
"E07000108" => "Dover",
"E07000109" => "Gravesham",
"E07000110" => "Maidstone",
"E07000111" => "Sevenoaks",
"E07000112" => "Folkestone and Hythe",
"E07000113" => "Swale",
"E07000114" => "Thanet",
"E07000115" => "Tonbridge and Malling",
"E07000116" => "Tunbridge Wells",
"E07000117" => "Burnley",
"E07000118" => "Chorley",
"E07000119" => "Fylde",
"E07000120" => "Hyndburn",
"E07000121" => "Lancaster",
"E07000122" => "Pendle",
"E07000123" => "Preston",
"E07000124" => "Ribble Valley",
"E07000125" => "Rossendale",
"E07000126" => "South Ribble",
"E07000127" => "West Lancashire",
"E07000128" => "Wyre",
"E07000129" => "Blaby",
"E07000130" => "Charnwood",
"E07000131" => "Harborough",
"E07000132" => "Hinckley and Bosworth",
"E07000133" => "Melton",
"E07000134" => "North West Leicestershire",
"E07000135" => "Oadby and Wigston",
"E07000136" => "Boston",
"E07000137" => "East Lindsey",
"E07000138" => "Lincoln",
"E07000139" => "North Kesteven",
"E07000140" => "South Holland",
"E07000141" => "South Kesteven",
"E07000142" => "West Lindsey",
"E07000143" => "Breckland",
"E07000144" => "Broadland",
"E07000145" => "Great Yarmouth",
"E07000146" => "King’s Lynn and West Norfolk",
"E07000147" => "North Norfolk",
"E07000148" => "Norwich",
"E07000149" => "South Norfolk",
"E06000061" => "North Northamptonshire",
"E06000062" => "West Northamptonshire",
"E07000170" => "Ashfield",
"E07000171" => "Bassetlaw",
"E07000172" => "Broxtowe",
"E07000173" => "Gedling",
"E07000174" => "Mansfield",
"E07000175" => "Newark and Sherwood",
"E07000176" => "Rushcliffe",
"E07000177" => "Cherwell",
"E07000178" => "Oxford",
"E07000179" => "South Oxfordshire",
"E07000180" => "Vale of White Horse",
"E07000181" => "West Oxfordshire",
"E07000192" => "Cannock Chase",
"E07000193" => "East Staffordshire",
"E07000194" => "Lichfield",
"E07000195" => "Newcastle-under-Lyme",
"E07000196" => "South Staffordshire",
"E07000197" => "Stafford",
"E07000198" => "Staffordshire Moorlands",
"E07000199" => "Tamworth",
"E07000200" => "Babergh",
"E07000202" => "Ipswich",
"E07000203" => "Mid Suffolk",
"E07000207" => "Elmbridge",
"E07000208" => "Epsom and Ewell",
"E07000209" => "Guildford",
"E07000210" => "Mole Valley",
"E07000211" => "Reigate and Banstead",
"E07000212" => "Runnymede",
"E07000213" => "Spelthorne",
"E07000214" => "Surrey Heath",
"E07000215" => "Tandridge",
"E07000216" => "Waverley",
"E07000217" => "Woking",
"E07000218" => "North Warwickshire",
"E07000219" => "Nuneaton and Bedworth",
"E07000220" => "Rugby",
"E07000221" => "Stratford-on-Avon",
"E07000222" => "Warwick",
"E07000223" => "Adur",
"E07000224" => "Arun",
"E07000225" => "Chichester",
"E07000226" => "Crawley",
"E07000227" => "Horsham",
"E07000228" => "Mid Sussex",
"E07000229" => "Worthing",
"E07000234" => "Bromsgrove",
"E07000235" => "Malvern Hills",
"E07000236" => "Redditch",
"E07000237" => "Worcester",
"E07000238" => "Wychavon",
"E07000239" => "Wyre Forest",
"E07000240" => "St Albans",
"E07000241" => "Welwyn Hatfield",
"E07000242" => "East Hertfordshire",
"E07000243" => "Stevenage",
"E07000244" => "East Suffolk",
"E07000245" => "West Suffolk",
"E08000001" => "Bolton",
"E08000002" => "Bury",
"E08000003" => "Manchester",
"E08000004" => "Oldham",
"E08000005" => "Rochdale",
"E08000006" => "Salford",
"E08000007" => "Stockport",
"E08000008" => "Tameside",
"E08000009" => "Trafford",
"E08000010" => "Wigan",
"E08000011" => "Knowsley",
"E08000012" => "Liverpool",
"E08000013" => "St. Helens",
"E08000014" => "Sefton",
"E08000015" => "Wirral",
"E08000016" => "Barnsley",
"E08000017" => "Doncaster",
"E08000018" => "Rotherham",
"E08000019" => "Sheffield",
"E08000021" => "Newcastle upon Tyne",
"E08000022" => "North Tyneside",
"E08000023" => "South Tyneside",
"E08000024" => "Sunderland",
"E08000025" => "Birmingham",
"E08000026" => "Coventry",
"E08000027" => "Dudley",
"E08000028" => "Sandwell",
"E08000029" => "Solihull",
"E06000066" => "Somerset",
"E08000030" => "Walsall",
"E08000031" => "Wolverhampton",
"E08000032" => "Bradford",
"E08000033" => "Calderdale",
"E08000034" => "Kirklees",
"E08000035" => "Leeds",
"E08000036" => "Wakefield",
"E08000037" => "Gateshead",
"E09000001" => "City of London",
"E09000002" => "Barking and Dagenham",
"E09000003" => "Barnet",
"E09000004" => "Bexley",
"E09000005" => "Brent",
"E09000006" => "Bromley",
"E09000007" => "Camden",
"E09000008" => "Croydon",
"E06000063" => "Cumberland",
"E09000009" => "Ealing",
"E09000010" => "Enfield",
"E09000011" => "Greenwich",
"E09000012" => "Hackney",
"E09000013" => "Hammersmith and Fulham",
"E09000014" => "Haringey",
"E09000015" => "Harrow",
"E09000016" => "Havering",
"E09000017" => "Hillingdon",
"E09000018" => "Hounslow",
"E09000019" => "Islington",
"E09000020" => "Kensington and Chelsea",
"E09000021" => "Kingston upon Thames",
"E09000022" => "Lambeth",
"E09000023" => "Lewisham",
"E09000024" => "Merton",
"E09000025" => "Newham",
"E09000026" => "Redbridge",
"E09000027" => "Richmond upon Thames",
"E09000028" => "Southwark",
"E09000029" => "Sutton",
"E09000030" => "Tower Hamlets",
"E09000031" => "Waltham Forest",
"E09000032" => "Wandsworth",
"E09000033" => "Westminster",
"E06000064" => "Westmorland and Furness",
"E06000065" => "North Yorkshire",
})
context "with 2026/27 form" do
let(:start_date) { Time.utc(2026, 4, 1) }
it "has the correct answer_options" do
expect(question.answer_options).to eq({
"" => "Select an option",
"E06000001" => "Hartlepool",
"E06000002" => "Middlesbrough",
"E06000003" => "Redcar and Cleveland",
"E06000004" => "Stockton-on-Tees",
"E06000005" => "Darlington",
"E06000006" => "Halton",
"E06000007" => "Warrington",
"E06000008" => "Blackburn with Darwen",
"E06000009" => "Blackpool",
"E06000010" => "Kingston upon Hull, City of",
"E06000011" => "East Riding of Yorkshire",
"E06000012" => "North East Lincolnshire",
"E06000013" => "North Lincolnshire",
"E06000014" => "York",
"E06000015" => "Derby",
"E06000016" => "Leicester",
"E06000017" => "Rutland",
"E06000018" => "Nottingham",
"E06000019" => "Herefordshire, County of",
"E06000020" => "Telford and Wrekin",
"E06000021" => "Stoke-on-Trent",
"E06000022" => "Bath and North East Somerset",
"E06000023" => "Bristol, City of",
"E06000024" => "North Somerset",
"E06000025" => "South Gloucestershire",
"E06000026" => "Plymouth",
"E06000027" => "Torbay",
"E06000030" => "Swindon",
"E06000031" => "Peterborough",
"E06000032" => "Luton",
"E06000033" => "Southend-on-Sea",
"E06000034" => "Thurrock",
"E06000035" => "Medway",
"E06000036" => "Bracknell Forest",
"E06000037" => "West Berkshire",
"E06000038" => "Reading",
"E06000039" => "Slough",
"E06000040" => "Windsor and Maidenhead",
"E06000041" => "Wokingham",
"E06000042" => "Milton Keynes",
"E06000043" => "Brighton and Hove",
"E06000044" => "Portsmouth",
"E06000045" => "Southampton",
"E06000046" => "Isle of Wight",
"E06000047" => "County Durham",
"E06000049" => "Cheshire East",
"E06000050" => "Cheshire West and Chester",
"E06000051" => "Shropshire",
"E06000052" => "Cornwall",
"E06000053" => "Isles of Scilly",
"E06000054" => "Wiltshire",
"E06000055" => "Bedford",
"E06000056" => "Central Bedfordshire",
"E06000057" => "Northumberland",
"E06000058" => "Bournemouth, Christchurch and Poole",
"E06000059" => "Dorset",
"E06000060" => "Buckinghamshire",
"E07000008" => "Cambridge",
"E07000009" => "East Cambridgeshire",
"E07000010" => "Fenland",
"E07000011" => "Huntingdonshire",
"E07000012" => "South Cambridgeshire",
"E07000032" => "Amber Valley",
"E07000033" => "Bolsover",
"E07000034" => "Chesterfield",
"E07000035" => "Derbyshire Dales",
"E07000036" => "Erewash",
"E07000037" => "High Peak",
"E07000038" => "North East Derbyshire",
"E07000039" => "South Derbyshire",
"E07000040" => "East Devon",
"E07000041" => "Exeter",
"E07000042" => "Mid Devon",
"E07000043" => "North Devon",
"E07000044" => "South Hams",
"E07000045" => "Teignbridge",
"E07000046" => "Torridge",
"E07000047" => "West Devon",
"E07000061" => "Eastbourne",
"E07000062" => "Hastings",
"E07000063" => "Lewes",
"E07000064" => "Rother",
"E07000065" => "Wealden",
"E07000066" => "Basildon",
"E07000067" => "Braintree",
"E07000068" => "Brentwood",
"E07000069" => "Castle Point",
"E07000070" => "Chelmsford",
"E07000071" => "Colchester",
"E07000072" => "Epping Forest",
"E07000073" => "Harlow",
"E07000074" => "Maldon",
"E07000075" => "Rochford",
"E07000076" => "Tendring",
"E07000077" => "Uttlesford",
"E07000078" => "Cheltenham",
"E07000079" => "Cotswold",
"E07000080" => "Forest of Dean",
"E07000081" => "Gloucester",
"E07000082" => "Stroud",
"E07000083" => "Tewkesbury",
"E07000084" => "Basingstoke and Deane",
"E07000085" => "East Hampshire",
"E07000086" => "Eastleigh",
"E07000087" => "Fareham",
"E07000088" => "Gosport",
"E07000089" => "Hart",
"E07000090" => "Havant",
"E07000091" => "New Forest",
"E07000092" => "Rushmoor",
"E07000093" => "Test Valley",
"E07000094" => "Winchester",
"E07000095" => "Broxbourne",
"E07000096" => "Dacorum",
"E07000098" => "Hertsmere",
"E07000099" => "North Hertfordshire",
"E07000102" => "Three Rivers",
"E07000103" => "Watford",
"E07000105" => "Ashford",
"E07000106" => "Canterbury",
"E07000107" => "Dartford",
"E07000108" => "Dover",
"E07000109" => "Gravesham",
"E07000110" => "Maidstone",
"E07000111" => "Sevenoaks",
"E07000112" => "Folkestone and Hythe",
"E07000113" => "Swale",
"E07000114" => "Thanet",
"E07000115" => "Tonbridge and Malling",
"E07000116" => "Tunbridge Wells",
"E07000117" => "Burnley",
"E07000118" => "Chorley",
"E07000119" => "Fylde",
"E07000120" => "Hyndburn",
"E07000121" => "Lancaster",
"E07000122" => "Pendle",
"E07000123" => "Preston",
"E07000124" => "Ribble Valley",
"E07000125" => "Rossendale",
"E07000126" => "South Ribble",
"E07000127" => "West Lancashire",
"E07000128" => "Wyre",
"E07000129" => "Blaby",
"E07000130" => "Charnwood",
"E07000131" => "Harborough",
"E07000132" => "Hinckley and Bosworth",
"E07000133" => "Melton",
"E07000134" => "North West Leicestershire",
"E07000135" => "Oadby and Wigston",
"E07000136" => "Boston",
"E07000137" => "East Lindsey",
"E07000138" => "Lincoln",
"E07000139" => "North Kesteven",
"E07000140" => "South Holland",
"E07000141" => "South Kesteven",
"E07000142" => "West Lindsey",
"E07000143" => "Breckland",
"E07000144" => "Broadland",
"E07000145" => "Great Yarmouth",
"E07000146" => "King’s Lynn and West Norfolk",
"E07000147" => "North Norfolk",
"E07000148" => "Norwich",
"E07000149" => "South Norfolk",
"E06000061" => "North Northamptonshire",
"E06000062" => "West Northamptonshire",
"E07000170" => "Ashfield",
"E07000171" => "Bassetlaw",
"E07000172" => "Broxtowe",
"E07000173" => "Gedling",
"E07000174" => "Mansfield",
"E07000175" => "Newark and Sherwood",
"E07000176" => "Rushcliffe",
"E07000177" => "Cherwell",
"E07000178" => "Oxford",
"E07000179" => "South Oxfordshire",
"E07000180" => "Vale of White Horse",
"E07000181" => "West Oxfordshire",
"E07000192" => "Cannock Chase",
"E07000193" => "East Staffordshire",
"E07000194" => "Lichfield",
"E07000195" => "Newcastle-under-Lyme",
"E07000196" => "South Staffordshire",
"E07000197" => "Stafford",
"E07000198" => "Staffordshire Moorlands",
"E07000199" => "Tamworth",
"E07000200" => "Babergh",
"E07000202" => "Ipswich",
"E07000203" => "Mid Suffolk",
"E07000207" => "Elmbridge",
"E07000208" => "Epsom and Ewell",
"E07000209" => "Guildford",
"E07000210" => "Mole Valley",
"E07000211" => "Reigate and Banstead",
"E07000212" => "Runnymede",
"E07000213" => "Spelthorne",
"E07000214" => "Surrey Heath",
"E07000215" => "Tandridge",
"E07000216" => "Waverley",
"E07000217" => "Woking",
"E07000218" => "North Warwickshire",
"E07000219" => "Nuneaton and Bedworth",
"E07000220" => "Rugby",
"E07000221" => "Stratford-on-Avon",
"E07000222" => "Warwick",
"E07000223" => "Adur",
"E07000224" => "Arun",
"E07000225" => "Chichester",
"E07000226" => "Crawley",
"E07000227" => "Horsham",
"E07000228" => "Mid Sussex",
"E07000229" => "Worthing",
"E07000234" => "Bromsgrove",
"E07000235" => "Malvern Hills",
"E07000236" => "Redditch",
"E07000237" => "Worcester",
"E07000238" => "Wychavon",
"E07000239" => "Wyre Forest",
"E07000240" => "St Albans",
"E07000241" => "Welwyn Hatfield",
"E07000242" => "East Hertfordshire",
"E07000243" => "Stevenage",
"E07000244" => "East Suffolk",
"E07000245" => "West Suffolk",
"E08000001" => "Bolton",
"E08000002" => "Bury",
"E08000003" => "Manchester",
"E08000004" => "Oldham",
"E08000005" => "Rochdale",
"E08000006" => "Salford",
"E08000007" => "Stockport",
"E08000008" => "Tameside",
"E08000009" => "Trafford",
"E08000010" => "Wigan",
"E08000011" => "Knowsley",
"E08000012" => "Liverpool",
"E08000013" => "St. Helens",
"E08000014" => "Sefton",
"E08000015" => "Wirral",
"E08000017" => "Doncaster",
"E08000018" => "Rotherham",
"E08000038" => "Barnsley",
"E08000039" => "Sheffield",
"E08000021" => "Newcastle upon Tyne",
"E08000022" => "North Tyneside",
"E08000023" => "South Tyneside",
"E08000024" => "Sunderland",
"E08000025" => "Birmingham",
"E08000026" => "Coventry",
"E08000027" => "Dudley",
"E08000028" => "Sandwell",
"E08000029" => "Solihull",
"E06000066" => "Somerset",
"E08000030" => "Walsall",
"E08000031" => "Wolverhampton",
"E08000032" => "Bradford",
"E08000033" => "Calderdale",
"E08000034" => "Kirklees",
"E08000035" => "Leeds",
"E08000036" => "Wakefield",
"E08000037" => "Gateshead",
"E09000001" => "City of London",
"E09000002" => "Barking and Dagenham",
"E09000003" => "Barnet",
"E09000004" => "Bexley",
"E09000005" => "Brent",
"E09000006" => "Bromley",
"E09000007" => "Camden",
"E09000008" => "Croydon",
"E06000063" => "Cumberland",
"E09000009" => "Ealing",
"E09000010" => "Enfield",
"E09000011" => "Greenwich",
"E09000012" => "Hackney",
"E09000013" => "Hammersmith and Fulham",
"E09000014" => "Haringey",
"E09000015" => "Harrow",
"E09000016" => "Havering",
"E09000017" => "Hillingdon",
"E09000018" => "Hounslow",
"E09000019" => "Islington",
"E09000020" => "Kensington and Chelsea",
"E09000021" => "Kingston upon Thames",
"E09000022" => "Lambeth",
"E09000023" => "Lewisham",
"E09000024" => "Merton",
"E09000025" => "Newham",
"E09000026" => "Redbridge",
"E09000027" => "Richmond upon Thames",
"E09000028" => "Southwark",
"E09000029" => "Sutton",
"E09000030" => "Tower Hamlets",
"E09000031" => "Waltham Forest",
"E09000032" => "Wandsworth",
"E09000033" => "Westminster",
"E06000064" => "Westmorland and Furness",
"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
@ -326,10 +325,6 @@ RSpec.describe Form::Lettings::Questions::La, type: :model do
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

5
spec/models/form/lettings/questions/ppcodenk_spec.rb

@ -1,15 +1,16 @@
require "rails_helper"
RSpec.describe Form::Lettings::Questions::Ppcodenk, type: :model do
include CollectionTimeHelper
subject(:question) { described_class.new(nil, question_definition, page) }
let(:question_definition) { nil }
let(:page) { instance_double(Form::Page) }
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: current_collection_start_date) }
before do
allow(form).to receive(:start_year_2024_or_later?).and_return(false)
allow(page).to receive(:subsection).and_return(subsection)
allow(subsection).to receive(:form).and_return(form)
end

5
spec/models/form/lettings/questions/previous_la_known_spec.rb

@ -1,15 +1,16 @@
require "rails_helper"
RSpec.describe Form::Lettings::Questions::PreviousLaKnown, type: :model do
include CollectionTimeHelper
subject(:question) { described_class.new(nil, question_definition, page) }
let(:question_definition) { nil }
let(:page) { instance_double(Form::Page) }
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: current_collection_start_date) }
before do
allow(form).to receive(:start_year_2024_or_later?).and_return(false)
allow(page).to receive(:subsection).and_return(subsection)
allow(subsection).to receive(:form).and_return(form)
end

11
spec/models/form/lettings/questions/reason_spec.rb

@ -1,16 +1,17 @@
require "rails_helper"
RSpec.describe Form::Lettings::Questions::Reason, type: :model do
include CollectionTimeHelper
subject(:question) { described_class.new(question_id, question_definition, page) }
let(:question_id) { nil }
let(:question_definition) { nil }
let(:page) { instance_double(Form::Page, id: "reason") }
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: current_collection_start_date) }
before do
allow(form).to receive_messages(start_year_2024_or_later?: false, start_year_2025_or_later?: false, start_year_2026_or_later?: false)
allow(page).to receive(:subsection).and_return(subsection)
allow(subsection).to receive(:form).and_return(form)
end
@ -41,7 +42,7 @@ RSpec.describe Form::Lettings::Questions::Reason, type: :model do
context "with 2024/25 form" do
before do
allow(form).to receive(:start_year_2024_or_later?).and_return(true)
allow(form).to receive_messages(start_year_2025_or_later?: false, start_year_2026_or_later?: false)
end
it "has the correct answer_options" do
@ -84,7 +85,7 @@ RSpec.describe Form::Lettings::Questions::Reason, type: :model do
context "with 2025/26 form" do
before do
allow(form).to receive(:start_year_2025_or_later?).and_return(true)
allow(form).to receive_messages(start_year_2025_or_later?: true, start_year_2026_or_later?: false)
end
it "has the correct answer_options" do
@ -128,7 +129,7 @@ RSpec.describe Form::Lettings::Questions::Reason, type: :model do
context "with 2026/27 form" do
before do
allow(form).to receive(:start_year_2026_or_later?).and_return(true)
allow(form).to receive_messages(start_year_2025_or_later?: true, start_year_2026_or_later?: true)
end
it "has the correct answer_options" do

5
spec/models/form/lettings/questions/reasonpref_spec.rb

@ -1,15 +1,16 @@
require "rails_helper"
RSpec.describe Form::Lettings::Questions::Reasonpref, type: :model do
include CollectionTimeHelper
subject(:question) { described_class.new(nil, question_definition, page) }
let(:question_definition) { nil }
let(:page) { instance_double(Form::Page) }
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: current_collection_start_date) }
before do
allow(form).to receive(:start_year_2024_or_later?).and_return(false)
allow(page).to receive(:subsection).and_return(subsection)
allow(subsection).to receive(:form).and_return(form)
end

5
spec/models/form/lettings/questions/renewal_spec.rb

@ -1,16 +1,17 @@
require "rails_helper"
RSpec.describe Form::Lettings::Questions::Renewal, type: :model do
include CollectionTimeHelper
subject(:question) { described_class.new(question_id, question_definition, page) }
let(:question_id) { nil }
let(:question_definition) { nil }
let(:page) { instance_double(Form::Page) }
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: current_collection_start_date) }
before do
allow(form).to receive(:start_year_2024_or_later?).and_return(false)
allow(page).to receive(:subsection).and_return(subsection)
allow(subsection).to receive(:form).and_return(form)
end

5
spec/models/form/lettings/questions/scheme_id_spec.rb

@ -1,18 +1,19 @@
require "rails_helper"
RSpec.describe Form::Lettings::Questions::SchemeId, type: :model do
include CollectionTimeHelper
subject(:question) { described_class.new(question_id, question_definition, page) }
let(:question_id) { nil }
let(:question_definition) { nil }
let(:page) { instance_double(Form::Page) }
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: current_collection_start_date) }
before do
allow(page).to receive(:subsection).and_return(subsection)
allow(subsection).to receive(:form).and_return(form)
allow(form).to receive(:start_year_2024_or_later?).and_return(false)
end
it "has correct page" do

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

@ -1,14 +1,15 @@
require "rails_helper"
RSpec.describe Form::Lettings::Questions::Sheltered, type: :model do
include CollectionTimeHelper
subject(:question) { described_class.new(nil, nil, page) }
let(:page) { instance_double(Form::Page) }
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: current_collection_start_date) }
before do
allow(form).to receive(:start_year_2024_or_later?).and_return(false)
allow(page).to receive(:subsection).and_return(subsection)
allow(subsection).to receive(:form).and_return(form)
end
@ -29,7 +30,7 @@ RSpec.describe Form::Lettings::Questions::Sheltered, type: :model do
let(:form) { instance_double(Form, start_date: Time.zone.local(2024, 4, 1)) }
before do
allow(form).to receive_messages(start_year_2024_or_later?: true, start_year_2025_or_later?: false)
allow(form).to receive_messages(start_year_2025_or_later?: false)
end
it "has the correct answer_options" do
@ -53,7 +54,7 @@ RSpec.describe Form::Lettings::Questions::Sheltered, type: :model do
let(:form) { instance_double(Form, start_date: Time.zone.local(2025, 4, 1)) }
before do
allow(form).to receive_messages(start_year_2024_or_later?: true, start_year_2025_or_later?: true)
allow(form).to receive_messages(start_year_2025_or_later?: true)
end
it "has the correct answer_options" do

13
spec/models/form/lettings/questions/tenancy_length_affordable_rent_spec.rb

@ -1,6 +1,8 @@
require "rails_helper"
RSpec.describe Form::Lettings::Questions::TenancyLengthAffordableRent, type: :model do
include CollectionTimeHelper
subject(:question) { described_class.new(nil, nil, page) }
let(:question_id) { nil }
@ -8,10 +10,9 @@ RSpec.describe Form::Lettings::Questions::TenancyLengthAffordableRent, type: :mo
let(:page) { instance_double(Form::Page, id: "affordable_tenancy_length") }
let(:subsection) { instance_double(Form::Subsection) }
let(:form) { instance_double(Form, start_date:) }
let(:start_date) { Time.utc(2023, 4, 1) }
let(:start_date) { current_collection_start_date }
before do
allow(form).to receive(:start_year_2024_or_later?).and_return(false)
allow(page).to receive(:subsection).and_return(subsection)
allow(subsection).to receive(:form).and_return(form)
end
@ -31,10 +32,6 @@ RSpec.describe Form::Lettings::Questions::TenancyLengthAffordableRent, type: :mo
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
@ -43,10 +40,6 @@ RSpec.describe Form::Lettings::Questions::TenancyLengthAffordableRent, type: :mo
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

13
spec/models/form/lettings/questions/tenancy_length_intermediate_rent_spec.rb

@ -1,6 +1,8 @@
require "rails_helper"
RSpec.describe Form::Lettings::Questions::TenancyLengthIntermediateRent, type: :model do
include CollectionTimeHelper
subject(:question) { described_class.new(nil, nil, page) }
let(:question_id) { nil }
@ -8,10 +10,9 @@ RSpec.describe Form::Lettings::Questions::TenancyLengthIntermediateRent, type: :
let(:page) { instance_double(Form::Page, id: "intermediate_tenancy_length") }
let(:subsection) { instance_double(Form::Subsection) }
let(:form) { instance_double(Form, start_date:) }
let(:start_date) { Time.utc(2023, 4, 1) }
let(:start_date) { current_collection_start_date }
before do
allow(form).to receive(:start_year_2024_or_later?).and_return(false)
allow(page).to receive(:subsection).and_return(subsection)
allow(subsection).to receive(:form).and_return(form)
end
@ -31,10 +32,6 @@ RSpec.describe Form::Lettings::Questions::TenancyLengthIntermediateRent, type: :
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
@ -43,10 +40,6 @@ RSpec.describe Form::Lettings::Questions::TenancyLengthIntermediateRent, type: :
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

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

@ -1,12 +1,14 @@
require "rails_helper"
RSpec.describe Form::Lettings::Questions::TenancyLengthPeriodic, type: :model do
include CollectionTimeHelper
subject(:question) { described_class.new(nil, nil, page) }
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:)), id: "periodic_tenancy_length") }
let(:start_date) { Time.utc(2023, 4, 1) }
let(:start_date) { current_collection_start_date }
it "has correct page" do
expect(question.page).to eq(page)
@ -23,10 +25,6 @@ RSpec.describe Form::Lettings::Questions::TenancyLengthPeriodic, type: :model do
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
@ -35,10 +33,6 @@ RSpec.describe Form::Lettings::Questions::TenancyLengthPeriodic, type: :model do
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

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

@ -1,10 +1,12 @@
require "rails_helper"
RSpec.describe Form::Lettings::Questions::TenancyLength, type: :model do
include CollectionTimeHelper
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:)), id: "tenancy_length") }
let(:start_date) { Time.utc(2023, 4, 1) }
let(:start_date) { current_collection_start_date }
it "has correct page" do
expect(question.page).to eq(page)
@ -34,10 +36,6 @@ RSpec.describe Form::Lettings::Questions::TenancyLength, type: :model do
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
@ -46,10 +44,6 @@ RSpec.describe Form::Lettings::Questions::TenancyLength, type: :model do
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

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

@ -1,10 +1,12 @@
require "rails_helper"
RSpec.describe Form::Lettings::Questions::TenancyOther, type: :model do
include CollectionTimeHelper
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:)), id: "tenancy_type") }
let(:start_date) { Time.utc(2023, 4, 1) }
let(:start_date) { current_collection_start_date }
it "has correct page" do
expect(question.page).to eq(page)
@ -25,10 +27,6 @@ RSpec.describe Form::Lettings::Questions::TenancyOther, type: :model do
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
@ -37,10 +35,6 @@ RSpec.describe Form::Lettings::Questions::TenancyOther, type: :model do
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

4
spec/models/form/lettings/questions/wheelchair_spec.rb

@ -1,6 +1,8 @@
require "rails_helper"
RSpec.describe Form::Lettings::Questions::Wheelchair, type: :model do
include CollectionTimeHelper
subject(:question) { described_class.new(nil, nil, page) }
let(:page) { instance_double(Form::Page) }
@ -8,7 +10,7 @@ RSpec.describe Form::Lettings::Questions::Wheelchair, type: :model do
before do
allow(page).to receive(:subsection).and_return(subsection)
allow(subsection).to receive(:form).and_return(instance_double(Form, start_year_2024_or_later?: false, start_date: Time.zone.local(2023, 4, 1)))
allow(subsection).to receive(:form).and_return(instance_double(Form, start_date: current_collection_start_date))
end
it "has correct page" do

11
spec/models/form/lettings/subsections/household_characteristics_spec.rb

@ -1,16 +1,17 @@
require "rails_helper"
RSpec.describe Form::Lettings::Subsections::HouseholdCharacteristics, type: :model do
include CollectionTimeHelper
subject(:household_characteristics) { described_class.new(subsection_id, subsection_definition, section) }
let(:subsection_id) { nil }
let(:subsection_definition) { nil }
let(:section) { instance_double(Form::Lettings::Sections::Household) }
let(:form) { instance_double(Form, start_date: Time.zone.local(2024, 4, 1)) }
let(:form) { instance_double(Form, start_date: current_collection_start_date) }
before do
allow(section).to receive(:form).and_return(form)
allow(form).to receive_messages(start_year_2024_or_later?: false, start_year_2025_or_later?: false, start_year_2026_or_later?: false)
end
it "has correct section" do
@ -19,7 +20,7 @@ RSpec.describe Form::Lettings::Subsections::HouseholdCharacteristics, type: :mod
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_messages(start_year_2025_or_later?: false, start_year_2026_or_later?: false)
end
it "has correct pages" do
@ -189,7 +190,7 @@ RSpec.describe Form::Lettings::Subsections::HouseholdCharacteristics, type: :mod
context "with start year 2025", metadata: { year: 25 } do
before do
allow(form).to receive_messages(start_year_2024_or_later?: true, start_year_2025_or_later?: true)
allow(form).to receive_messages(start_year_2025_or_later?: true, start_year_2026_or_later?: false)
end
it "has correct pages" do
@ -359,7 +360,7 @@ RSpec.describe Form::Lettings::Subsections::HouseholdCharacteristics, type: :mod
context "with start year 2026", metadata: { year: 26 } do
before do
allow(form).to receive_messages(start_year_2024_or_later?: true, start_year_2025_or_later?: true, start_year_2026_or_later?: true)
allow(form).to receive_messages(start_year_2025_or_later?: true, start_year_2026_or_later?: true)
end
it "has correct pages" do

11
spec/models/form/lettings/subsections/household_situation_spec.rb

@ -1,16 +1,17 @@
require "rails_helper"
RSpec.describe Form::Lettings::Subsections::HouseholdSituation, type: :model do
include CollectionTimeHelper
subject(:household_situation) { described_class.new(subsection_id, subsection_definition, section) }
let(:subsection_id) { nil }
let(:subsection_definition) { nil }
let(:section) { instance_double(Form::Lettings::Sections::Household) }
let(:form) { instance_double(Form, start_date: Time.zone.local(2024, 4, 1)) }
let(:form) { instance_double(Form, start_date: current_collection_start_date) }
before do
allow(section).to receive(:form).and_return(form)
allow(form).to receive_messages(start_year_2024_or_later?: false, start_year_2025_or_later?: false, start_year_2026_or_later?: false)
end
it "has correct section" do
@ -19,7 +20,7 @@ RSpec.describe Form::Lettings::Subsections::HouseholdSituation, type: :model do
context "with form year is 2024", metadata: { year: 24 } do
before do
allow(form).to receive(:start_year_2024_or_later?).and_return(true)
allow(form).to receive_messages(start_year_2025_or_later?: false, start_year_2026_or_later?: false)
end
it "has correct pages" do
@ -50,7 +51,7 @@ RSpec.describe Form::Lettings::Subsections::HouseholdSituation, type: :model do
context "with form year is 2025", metadata: { year: 25 } do
before do
allow(form).to receive_messages(start_year_2024_or_later?: true, start_year_2025_or_later?: true)
allow(form).to receive_messages(start_year_2025_or_later?: true, start_year_2026_or_later?: false)
end
it "has correct pages" do
@ -83,7 +84,7 @@ RSpec.describe Form::Lettings::Subsections::HouseholdSituation, type: :model do
context "with form year is 2026", metadata: { year: 26 } do
before do
allow(form).to receive_messages(start_year_2024_or_later?: true, start_year_2025_or_later?: true, start_year_2026_or_later?: true)
allow(form).to receive_messages(start_year_2025_or_later?: true, start_year_2026_or_later?: true)
end
it "has correct pages" do

4
spec/models/form/sales/pages/buyer1_ethnic_background_arab_spec.rb

@ -1,11 +1,13 @@
require "rails_helper"
RSpec.describe Form::Sales::Pages::Buyer1EthnicBackgroundArab, type: :model do
include CollectionTimeHelper
subject(:page) { described_class.new(page_id, page_definition, subsection) }
let(:page_id) { nil }
let(:page_definition) { nil }
let(:subsection) { instance_double(Form::Subsection, form: instance_double(Form, start_date: Time.zone.local(2023, 4, 1), start_year_2024_or_later?: false)) }
let(:subsection) { instance_double(Form::Subsection, form: instance_double(Form, start_date: current_collection_start_date)) }
it "has correct subsection" do
expect(page.subsection).to eq(subsection)

4
spec/models/form/sales/pages/buyer1_ethnic_background_asian_spec.rb

@ -1,11 +1,13 @@
require "rails_helper"
RSpec.describe Form::Sales::Pages::Buyer1EthnicBackgroundAsian, type: :model do
include CollectionTimeHelper
subject(:page) { described_class.new(page_id, page_definition, subsection) }
let(:page_id) { nil }
let(:page_definition) { nil }
let(:subsection) { instance_double(Form::Subsection, form: instance_double(Form, start_date: Time.zone.local(2023, 4, 1), start_year_2024_or_later?: false)) }
let(:subsection) { instance_double(Form::Subsection, form: instance_double(Form, start_date: current_collection_start_date)) }
it "has correct subsection" do
expect(page.subsection).to eq(subsection)

4
spec/models/form/sales/pages/buyer1_ethnic_background_black_spec.rb

@ -1,11 +1,13 @@
require "rails_helper"
RSpec.describe Form::Sales::Pages::Buyer1EthnicBackgroundBlack, type: :model do
include CollectionTimeHelper
subject(:page) { described_class.new(page_id, page_definition, subsection) }
let(:page_id) { nil }
let(:page_definition) { nil }
let(:subsection) { instance_double(Form::Subsection, form: instance_double(Form, start_date: Time.zone.local(2023, 4, 1), start_year_2024_or_later?: false)) }
let(:subsection) { instance_double(Form::Subsection, form: instance_double(Form, start_date: current_collection_start_date)) }
it "has correct subsection" do
expect(page.subsection).to eq(subsection)

4
spec/models/form/sales/pages/buyer1_ethnic_background_mixed_spec.rb

@ -1,11 +1,13 @@
require "rails_helper"
RSpec.describe Form::Sales::Pages::Buyer1EthnicBackgroundMixed, type: :model do
include CollectionTimeHelper
subject(:page) { described_class.new(page_id, page_definition, subsection) }
let(:page_id) { nil }
let(:page_definition) { nil }
let(:subsection) { instance_double(Form::Subsection, form: instance_double(Form, start_date: Time.zone.local(2023, 4, 1), start_year_2024_or_later?: false)) }
let(:subsection) { instance_double(Form::Subsection, form: instance_double(Form, start_date: current_collection_start_date)) }
it "has correct subsection" do
expect(page.subsection).to eq(subsection)

5
spec/models/form/sales/pages/buyer1_ethnic_background_white_spec.rb

@ -1,15 +1,16 @@
require "rails_helper"
RSpec.describe Form::Sales::Pages::Buyer1EthnicBackgroundWhite, type: :model do
include CollectionTimeHelper
subject(:page) { described_class.new(page_id, page_definition, subsection) }
let(:page_id) { nil }
let(:page_definition) { nil }
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: current_collection_start_date) }
before do
allow(form).to receive(:start_year_2024_or_later?).and_return(false)
allow(subsection).to receive(:form).and_return(form)
end

4
spec/models/form/sales/pages/buyer1_ethnic_group_spec.rb

@ -1,11 +1,13 @@
require "rails_helper"
RSpec.describe Form::Sales::Pages::Buyer1EthnicGroup, type: :model do
include CollectionTimeHelper
subject(:page) { described_class.new(page_id, page_definition, subsection) }
let(:page_id) { nil }
let(:page_definition) { nil }
let(:form) { Form.new(nil, 2023, [], "sales") }
let(:form) { Form.new(nil, current_collection_start_year, [], "sales") }
let(:subsection) { instance_double(Form::Subsection, form:, depends_on: nil) }
it "has correct subsection" do

4
spec/models/form/sales/pages/buyer1_live_in_property_spec.rb

@ -1,11 +1,13 @@
require "rails_helper"
RSpec.describe Form::Sales::Pages::Buyer1LiveInProperty, type: :model do
include CollectionTimeHelper
subject(:page) { described_class.new(page_id, page_definition, subsection) }
let(:page_id) { nil }
let(:page_definition) { nil }
let(:form) { Form.new(nil, 2023, [], "sales") }
let(:form) { Form.new(nil, current_collection_start_year, [], "sales") }
let(:subsection) { instance_double(Form::Subsection, form:, enabled?: true, depends_on: nil) }
it "has correct subsection" do

4
spec/models/form/sales/pages/buyer1_working_situation_spec.rb

@ -1,11 +1,13 @@
require "rails_helper"
RSpec.describe Form::Sales::Pages::Buyer1WorkingSituation, type: :model do
include CollectionTimeHelper
subject(:page) { described_class.new(page_id, page_definition, subsection) }
let(:page_id) { nil }
let(:page_definition) { nil }
let(:form) { Form.new(nil, 2023, [], "sales") }
let(:form) { Form.new(nil, current_collection_start_year, [], "sales") }
let(:subsection) { instance_double(Form::Subsection, form:, enabled?: true) }
it "has correct subsection" do

4
spec/models/form/sales/pages/buyer2_ethnic_group_spec.rb

@ -1,11 +1,13 @@
require "rails_helper"
RSpec.describe Form::Sales::Pages::Buyer2EthnicGroup, type: :model do
include CollectionTimeHelper
subject(:page) { described_class.new(page_id, page_definition, subsection) }
let(:page_id) { nil }
let(:page_definition) { nil }
let(:form) { Form.new(nil, 2023, [], "sales") }
let(:form) { Form.new(nil, current_collection_start_year, [], "sales") }
let(:subsection) { instance_double(Form::Subsection, form:, depends_on: nil) }
it "has correct subsection" do

4
spec/models/form/sales/pages/buyer2_live_in_property_spec.rb

@ -1,11 +1,13 @@
require "rails_helper"
RSpec.describe Form::Sales::Pages::Buyer2LiveInProperty, type: :model do
include CollectionTimeHelper
subject(:page) { described_class.new(page_id, page_definition, subsection) }
let(:page_id) { nil }
let(:page_definition) { nil }
let(:form) { Form.new(nil, 2023, [], "sales") }
let(:form) { Form.new(nil, current_collection_start_year, [], "sales") }
let(:subsection) { instance_double(Form::Subsection, form:, depends_on: nil, enabled?: true) }
it "has correct subsection" do

4
spec/models/form/sales/pages/buyer2_relationship_to_buyer1_spec.rb

@ -1,11 +1,13 @@
require "rails_helper"
RSpec.describe Form::Sales::Pages::Buyer2RelationshipToBuyer1, type: :model do
include CollectionTimeHelper
subject(:page) { described_class.new(page_id, page_definition, subsection) }
let(:page_id) { nil }
let(:page_definition) { nil }
let(:subsection) { instance_double(Form::Subsection, form: instance_double(Form, start_date: Time.zone.local(2023, 4, 1), start_year_2024_or_later?: false)) }
let(:subsection) { instance_double(Form::Subsection, form: instance_double(Form, start_date: current_collection_start_date)) }
it "has correct subsection" do
expect(page.subsection).to eq(subsection)

4
spec/models/form/sales/pages/buyer2_working_situation_spec.rb

@ -1,11 +1,13 @@
require "rails_helper"
RSpec.describe Form::Sales::Pages::Buyer2WorkingSituation, type: :model do
include CollectionTimeHelper
subject(:page) { described_class.new(page_id, page_definition, subsection) }
let(:page_id) { nil }
let(:page_definition) { nil }
let(:form) { Form.new(nil, 2023, [], "sales") }
let(:form) { Form.new(nil, current_collection_start_year, [], "sales") }
let(:subsection) { instance_double(Form::Subsection, form:, depends_on: nil) }
it "has correct subsection" do

4
spec/models/form/sales/pages/buyer_interview_spec.rb

@ -1,11 +1,13 @@
require "rails_helper"
RSpec.describe Form::Sales::Pages::BuyerInterview, type: :model do
include CollectionTimeHelper
subject(:page) { described_class.new(page_id, page_definition, subsection, joint_purchase: false) }
let(:page_id) { "buyer_interview" }
let(:page_definition) { nil }
let(:form) { instance_double(Form, start_date: Time.zone.local(2023, 4, 1), start_year_2024_or_later?: false) }
let(:form) { instance_double(Form, start_date: current_collection_start_date) }
let(:subsection) { instance_double(Form::Subsection, form:, id: "setup", copy_key: "subsection_copy_key") }
it "has correct subsection" do

4
spec/models/form/sales/pages/buyer_live_spec.rb

@ -13,7 +13,7 @@ RSpec.describe Form::Sales::Pages::BuyerLive, type: :model do
let(:form) { instance_double(Form, start_date: Time.zone.local(2024, 4, 1)) }
before do
allow(form).to receive_messages(start_year_2024_or_later?: true, start_year_2025_or_later?: false)
allow(form).to receive_messages(start_year_2025_or_later?: false)
allow(subsection).to receive(:form).and_return(form)
end
@ -44,7 +44,7 @@ RSpec.describe Form::Sales::Pages::BuyerLive, type: :model do
let(:form) { instance_double(Form, start_date: Time.zone.local(2025, 4, 1)) }
before do
allow(form).to receive_messages(start_year_2024_or_later?: true, start_year_2025_or_later?: true)
allow(form).to receive_messages(start_year_2025_or_later?: true)
allow(subsection).to receive(:form).and_return(form)
end

4
spec/models/form/sales/pages/discount_spec.rb

@ -1,6 +1,8 @@
require "rails_helper"
RSpec.describe Form::Sales::Pages::Discount, type: :model do
include CollectionTimeHelper
subject(:page) { described_class.new(page_id, page_definition, subsection) }
let(:page_id) { nil }
@ -8,7 +10,7 @@ RSpec.describe Form::Sales::Pages::Discount, type: :model do
let(:subsection) { instance_double(Form::Subsection) }
before do
allow(subsection).to receive(:form).and_return(instance_double(Form, start_year_2024_or_later?: false, start_date: Time.zone.local(2023, 4, 1)))
allow(subsection).to receive(:form).and_return(instance_double(Form, start_date: current_collection_start_date))
end
it "has correct subsection" do

4
spec/models/form/sales/pages/joint_purchase_spec.rb

@ -10,7 +10,7 @@ RSpec.describe Form::Sales::Pages::JointPurchase, type: :model do
let(:subsection) { instance_double(Form::Subsection, form: instance_double(Form, start_date: Time.zone.local(2024, 4, 1))) }
before do
allow(subsection.form).to receive_messages(start_year_2024_or_later?: true, start_year_2025_or_later?: false)
allow(subsection.form).to receive_messages(start_year_2025_or_later?: false)
end
it "has correct subsection" do
@ -42,7 +42,7 @@ RSpec.describe Form::Sales::Pages::JointPurchase, type: :model do
let(:subsection) { instance_double(Form::Subsection, form: instance_double(Form, start_date: Time.zone.local(2025, 4, 1))) }
before do
allow(subsection.form).to receive_messages(start_year_2024_or_later?: true, start_year_2025_or_later?: true)
allow(subsection.form).to receive_messages(start_year_2025_or_later?: true)
end
it "has correct depends_on" do

4
spec/models/form/sales/pages/person_relationship_to_buyer1_spec.rb

@ -1,10 +1,12 @@
require "rails_helper"
RSpec.describe Form::Sales::Pages::PersonRelationshipToBuyer1, type: :model do
include CollectionTimeHelper
subject(:page) { described_class.new(page_id, page_definition, subsection, person_index:) }
let(:page_definition) { nil }
let(:subsection) { instance_double(Form::Subsection, form: instance_double(Form, start_date: Time.zone.local(2023, 4, 1), start_year_2024_or_later?: false, person_question_count: 4)) }
let(:subsection) { instance_double(Form::Subsection, form: instance_double(Form, start_date: current_collection_start_date, person_question_count: 4)) }
let(:person_index) { 1 }
let(:page_id) { "person_1_relationship_to_buyer_1" }

4
spec/models/form/sales/pages/privacy_notice_spec.rb

@ -1,12 +1,14 @@
require "rails_helper"
RSpec.describe Form::Sales::Pages::PrivacyNotice, type: :model do
include CollectionTimeHelper
subject(:page) { described_class.new(page_id, page_definition, subsection, joint_purchase: false) }
let(:page_id) { "privacy_notice" }
let(:page_definition) { nil }
let(:subsection) { instance_double(Form::Subsection, id: "setup", copy_key: "setup") }
let(:form) { instance_double(Form, start_date: Time.zone.local(2023, 4, 1), start_year_2024_or_later?: false) }
let(:form) { instance_double(Form, start_date: current_collection_start_date) }
before do
allow(subsection).to receive(:form).and_return(form)

2
spec/models/form/sales/pages/property_wheelchair_accessible_spec.rb

@ -7,7 +7,7 @@ RSpec.describe Form::Sales::Pages::PropertyWheelchairAccessible, type: :model do
let(:page_id) { nil }
let(:page_definition) { nil }
let(:form) { instance_double(Form, start_year_2024_or_later?: true, start_date: current_collection_start_date) }
let(:form) { instance_double(Form, start_date: current_collection_start_date) }
let(:subsection) { instance_double(Form::Subsection, enabled?: true, form:) }
let(:saledate) { current_collection_start_date }

4
spec/models/form/sales/pages/purchase_price_spec.rb

@ -1,6 +1,8 @@
require "rails_helper"
RSpec.describe Form::Sales::Pages::PurchasePrice, type: :model do
include CollectionTimeHelper
subject(:page) { described_class.new(page_id, page_definition, subsection) }
let(:page_id) { nil }
@ -8,7 +10,7 @@ RSpec.describe Form::Sales::Pages::PurchasePrice, type: :model do
let(:subsection) { instance_double(Form::Subsection) }
before do
allow(subsection).to receive_messages(form: instance_double(Form, start_year_2024_or_later?: true, start_date: Time.zone.local(2023, 4, 1), start_year_2025_or_later?: true, start_year_2026_or_later?: false), id: "discounted_ownership_scheme")
allow(subsection).to receive_messages(form: instance_double(Form, start_date: current_collection_start_date, start_year_2025_or_later?: true, start_year_2026_or_later?: true), id: "discounted_ownership_scheme")
end
it "has correct subsection" do

2
spec/models/form/sales/pages/shared_ownership_type_spec.rb

@ -7,7 +7,7 @@ RSpec.describe Form::Sales::Pages::SharedOwnershipType, type: :model do
let(:page_id) { nil }
let(:page_definition) { nil }
let(:subsection) { instance_double(Form::Subsection, form: instance_double(Form, start_date: current_collection_start_date, start_year_2024_or_later?: true)) }
let(:subsection) { instance_double(Form::Subsection, form: instance_double(Form, start_date: current_collection_start_date)) }
it "has correct subsection" do
expect(page.subsection).to eq(subsection)

35
spec/models/form/sales/pages/uprn_spec.rb

@ -1,15 +1,16 @@
require "rails_helper"
RSpec.describe Form::Sales::Pages::Uprn, type: :model do
include CollectionTimeHelper
subject(:page) { described_class.new(page_id, page_definition, subsection) }
let(:page_id) { nil }
let(:page_definition) { nil }
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: current_collection_start_date) }
before do
allow(form).to receive(:start_year_2024_or_later?).and_return(false)
allow(subsection).to receive(:form).and_return(form)
end
@ -43,32 +44,14 @@ RSpec.describe Form::Sales::Pages::Uprn, type: :model do
context "when log is present" do
let(:log) { build(:sales_log) }
context "with 2023/24 form" do
it "points to address page" do
expect(page.skip_href(log)).to eq(
"address",
)
end
it "has correct skip_text" do
expect(page.skip_text).to eq("Enter address instead")
end
it "points to address search page" do
expect(page.skip_href(log)).to eq(
"address-matcher",
)
end
context "with 2024/25 form" do
before do
allow(form).to receive(:start_year_2024_or_later?).and_return(true)
end
it "points to address search page" do
expect(page.skip_href(log)).to eq(
"address-matcher",
)
end
it "has correct skip_text" do
expect(page.skip_text).to eq("Search for address instead")
end
it "has correct skip_text" do
expect(page.skip_text).to eq("Search for address instead")
end
end
end

4
spec/models/form/sales/questions/buyer1_ethnic_background_arab_spec.rb

@ -1,11 +1,13 @@
require "rails_helper"
RSpec.describe Form::Sales::Questions::Buyer1EthnicBackgroundArab, type: :model do
include CollectionTimeHelper
subject(:question) { described_class.new(question_id, question_definition, page) }
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), start_year_2024_or_later?: false))) }
let(:page) { instance_double(Form::Page, subsection: instance_double(Form::Subsection, form: instance_double(Form, start_date: current_collection_start_date))) }
it "has correct page" do
expect(question.page).to eq(page)

4
spec/models/form/sales/questions/buyer1_ethnic_background_asian_spec.rb

@ -1,11 +1,13 @@
require "rails_helper"
RSpec.describe Form::Sales::Questions::Buyer1EthnicBackgroundAsian, type: :model do
include CollectionTimeHelper
subject(:question) { described_class.new(question_id, question_definition, page) }
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), start_year_2024_or_later?: false))) }
let(:page) { instance_double(Form::Page, subsection: instance_double(Form::Subsection, form: instance_double(Form, start_date: current_collection_start_date))) }
it "has correct page" do
expect(question.page).to eq(page)

4
spec/models/form/sales/questions/buyer1_ethnic_background_black_spec.rb

@ -1,11 +1,13 @@
require "rails_helper"
RSpec.describe Form::Sales::Questions::Buyer1EthnicBackgroundBlack, type: :model do
include CollectionTimeHelper
subject(:question) { described_class.new(question_id, question_definition, page) }
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), start_year_2024_or_later?: false))) }
let(:page) { instance_double(Form::Page, subsection: instance_double(Form::Subsection, form: instance_double(Form, start_date: current_collection_start_date))) }
it "has correct page" do
expect(question.page).to eq(page)

4
spec/models/form/sales/questions/buyer1_ethnic_background_mixed_spec.rb

@ -1,11 +1,13 @@
require "rails_helper"
RSpec.describe Form::Sales::Questions::Buyer1EthnicBackgroundMixed, type: :model do
include CollectionTimeHelper
subject(:question) { described_class.new(question_id, question_definition, page) }
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), start_year_2024_or_later?: false))) }
let(:page) { instance_double(Form::Page, subsection: instance_double(Form::Subsection, form: instance_double(Form, start_date: current_collection_start_date))) }
it "has correct page" do
expect(question.page).to eq(page)

4
spec/models/form/sales/questions/buyer1_ethnic_group_spec.rb

@ -1,11 +1,13 @@
require "rails_helper"
RSpec.describe Form::Sales::Questions::Buyer1EthnicGroup, type: :model do
include CollectionTimeHelper
subject(:question) { described_class.new(question_id, question_definition, page) }
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), start_year_2024_or_later?: false))) }
let(:page) { instance_double(Form::Page, subsection: instance_double(Form::Subsection, form: instance_double(Form, start_date: current_collection_start_date))) }
it "has correct page" do
expect(question.page).to eq(page)

4
spec/models/form/sales/questions/buyer1_live_in_property_spec.rb

@ -1,11 +1,13 @@
require "rails_helper"
RSpec.describe Form::Sales::Questions::Buyer1LiveInProperty, type: :model do
include CollectionTimeHelper
subject(:question) { described_class.new(question_id, question_definition, page) }
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), start_year_2024_or_later?: false))) }
let(:page) { instance_double(Form::Page, subsection: instance_double(Form::Subsection, form: instance_double(Form, start_date: current_collection_start_date))) }
it "has correct page" do
expect(question.page).to eq(page)

4
spec/models/form/sales/questions/buyer_interview_spec.rb

@ -1,11 +1,13 @@
require "rails_helper"
RSpec.describe Form::Sales::Questions::BuyerInterview, type: :model do
include CollectionTimeHelper
subject(:question) { described_class.new(question_id, question_definition, page, joint_purchase: false) }
let(:question_id) { nil }
let(:question_definition) { nil }
let(:form) { instance_double(Form, start_date: Time.zone.local(2023, 4, 1), start_year_2024_or_later?: true) }
let(:form) { instance_double(Form, start_date: current_collection_start_date) }
let(:subsection) { instance_double(Form::Subsection, form:, copy_key: "setup") }
let(:page) { instance_double(Form::Page, subsection:) }

1
spec/models/form/sales/questions/buyer_live_spec.rb

@ -12,7 +12,6 @@ RSpec.describe Form::Sales::Questions::BuyerLive, type: :model do
let(:form) { instance_double(Form, start_date: current_collection_start_date) }
before do
allow(form).to receive(:start_year_2024_or_later?).and_return(true)
allow(page).to receive(:subsection).and_return(subsection)
allow(subsection).to receive(:form).and_return(form)
end

3
spec/models/form/sales/questions/mortgageused_spec.rb

@ -11,11 +11,10 @@ RSpec.describe Form::Sales::Questions::Mortgageused, type: :model do
let(:staircase) { nil }
let(:saledate) { Time.zone.today }
let(:log) { build(:sales_log, :in_progress, ownershipsch:, stairowned:, staircase:) }
let(:start_year_2024_or_later?) { true }
let(:start_year_2025_or_later?) { true }
let(:start_year_2026_or_later?) { true }
let(:subsection_id) { "shared_ownership_initial_purchase" }
let(:form) { instance_double(Form, type: "sales", start_date: saledate, start_year_2024_or_later?: start_year_2024_or_later?, start_year_2025_or_later?: start_year_2025_or_later?, start_year_2026_or_later?: start_year_2026_or_later?) }
let(:form) { instance_double(Form, type: "sales", start_date: saledate, start_year_2025_or_later?: start_year_2025_or_later?, start_year_2026_or_later?: start_year_2026_or_later?) }
let(:page) { instance_double(Form::Page, subsection: instance_double(Form::Subsection, form:, id: subsection_id, copy_key: subsection_id)) }
context "when it is a shared ownership scheme" do

62
spec/models/form/sales/questions/nationality_all_group_spec.rb

@ -1,11 +1,13 @@
require "rails_helper"
RSpec.describe Form::Sales::Questions::NationalityAllGroup, type: :model do
include CollectionTimeHelper
subject(:question) { described_class.new("some_id", nil, page, buyer_index) }
let(:buyer_index) { 1 }
let(:page) { instance_double(Form::Page, subsection: instance_double(Form::Subsection, form: instance_double(Form, start_date: Time.zone.local(2023, 4, 1), start_year_2024_or_later?: false))) }
let(:form) { instance_double(Form, start_date: current_collection_start_date) }
let(:page) { instance_double(Form::Page, subsection: instance_double(Form::Subsection, form:)) }
it "has correct page" do
expect(question.page).to be page
@ -38,13 +40,33 @@ RSpec.describe Form::Sales::Questions::NationalityAllGroup, type: :model do
expect(question.conditional_for).to eq({ "nationality_all" => [12] })
end
it "has correct question_number" do
expect(question.question_number).to eq(24)
end
it "has correct check_answers_card_number" do
expect(question.check_answers_card_number).to eq(1)
end
context "with 2024/25 form" do
let(:form) { instance_double(Form, start_date: Time.zone.local(2024, 4, 1)) }
it "has correct question_number" do
expect(question.question_number).to eq(26)
end
end
context "with 2025/26 form" do
let(:form) { instance_double(Form, start_date: Time.zone.local(2025, 4, 1)) }
it "has correct question_number" do
expect(question.question_number).to eq(24)
end
end
context "with 2026/27 form" do
let(:form) { instance_double(Form, start_date: Time.zone.local(2026, 4, 1)) }
it "has correct question_number" do
expect(question.question_number).to eq(26)
end
end
end
context "with buyer 2" do
@ -54,12 +76,32 @@ RSpec.describe Form::Sales::Questions::NationalityAllGroup, type: :model do
expect(question.conditional_for).to eq({ "nationality_all_buyer2" => [12] })
end
it "has correct question_number" do
expect(question.question_number).to eq(32)
end
it "has correct check_answers_card_number" do
expect(question.check_answers_card_number).to eq(2)
end
context "with 2024/25 form" do
let(:form) { instance_double(Form, start_date: Time.zone.local(2024, 4, 1)) }
it "has correct question_number" do
expect(question.question_number).to eq(34)
end
end
context "with 2025/26 form" do
let(:form) { instance_double(Form, start_date: Time.zone.local(2025, 4, 1)) }
it "has correct question_number" do
expect(question.question_number).to eq(32)
end
end
context "with 2026/27 form" do
let(:form) { instance_double(Form, start_date: Time.zone.local(2026, 4, 1)) }
it "has correct question_number" do
expect(question.question_number).to eq(35)
end
end
end
end

4
spec/models/form/sales/questions/number_joint_buyers_spec.rb

@ -1,6 +1,8 @@
require "rails_helper"
RSpec.describe Form::Sales::Questions::NumberJointBuyers, type: :model do
include CollectionTimeHelper
subject(:question) { described_class.new(question_id, question_definition, page) }
let(:question_id) { nil }
@ -10,7 +12,7 @@ RSpec.describe Form::Sales::Questions::NumberJointBuyers, type: :model do
before do
allow(page).to receive(:subsection).and_return(subsection)
allow(subsection).to receive(:form).and_return(instance_double(Form, start_year_2024_or_later?: false, start_date: Time.zone.local(2023, 4, 1)))
allow(subsection).to receive(:form).and_return(instance_double(Form, start_date: current_collection_start_date))
end
it "has correct page" do

4
spec/models/form/sales/questions/person_age_spec.rb

@ -1,11 +1,13 @@
require "rails_helper"
RSpec.describe Form::Sales::Questions::PersonAge, type: :model do
include CollectionTimeHelper
subject(:question) { described_class.new(question_id, question_definition, page, person_index:) }
let(:question_id) { "age3" }
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), start_year_2024_or_later?: false, person_question_count: 4))) }
let(:page) { instance_double(Form::Page, subsection: instance_double(Form::Subsection, form: instance_double(Form, start_date: current_collection_start_date, person_question_count: 4))) }
let(:person_index) { 2 }
it "has correct page" do

4
spec/models/form/sales/questions/property_wheelchair_accessible_spec.rb

@ -1,6 +1,8 @@
require "rails_helper"
RSpec.describe Form::Sales::Questions::PropertyWheelchairAccessible, type: :model do
include CollectionTimeHelper
subject(:question) { described_class.new(question_id, question_definition, page) }
let(:question_id) { nil }
@ -10,7 +12,7 @@ RSpec.describe Form::Sales::Questions::PropertyWheelchairAccessible, type: :mode
before do
allow(page).to receive(:subsection).and_return(subsection)
allow(subsection).to receive(:form).and_return(instance_double(Form, start_year_2024_or_later?: false, start_date: Time.zone.local(2023, 4, 1)))
allow(subsection).to receive(:form).and_return(instance_double(Form, start_date: current_collection_start_date))
end
it "has correct page" do

12
spec/models/form/sales/questions/shared_ownership_type_spec.rb

@ -12,10 +12,6 @@ RSpec.describe Form::Sales::Questions::SharedOwnershipType, type: :model do
let(:subsection) { instance_double(Form::Subsection, form:) }
let(:page) { instance_double(Form::Page, subsection:) }
before do
allow(form).to receive(:start_year_2024_or_later?).and_return(true)
end
it "has correct page" do
expect(question.page).to eq(page)
end
@ -35,10 +31,6 @@ RSpec.describe Form::Sales::Questions::SharedOwnershipType, type: :model do
context "when form start date is 2023/24" do
let(:start_date) { Time.zone.local(2023, 4, 2) }
before do
allow(form).to receive(:start_year_2024_or_later?).and_return(false)
end
it "has the correct answer_options" do
expect(question.answer_options).to eq({
"2" => { "value" => "Shared Ownership (old model lease)" },
@ -58,10 +50,6 @@ RSpec.describe Form::Sales::Questions::SharedOwnershipType, type: :model do
end
context "when form start date is on or after 2024/25" do
before do
allow(form).to receive(:start_year_2024_or_later?).and_return(true)
end
it "shows shows correct top_guidance_partial" do
expect(question.top_guidance_partial).to eq("shared_ownership_type_definitions")
end

6
spec/models/form/sales/subsections/household_situation_spec.rb

@ -3,7 +3,7 @@ require "rails_helper"
RSpec.describe Form::Sales::Subsections::HouseholdSituation, type: :model do
subject(:household_characteristics) { described_class.new(nil, nil, section) }
let(:form) { instance_double(Form, start_year_2024_or_later?: true, start_year_2025_or_later?: false) }
let(:form) { instance_double(Form, start_year_2025_or_later?: false) }
let(:section) { instance_double(Form::Sales::Sections::Household, form:) }
it "has correct section" do
@ -11,7 +11,7 @@ RSpec.describe Form::Sales::Subsections::HouseholdSituation, type: :model do
end
context "when the start year is 2024" do
let(:form) { instance_double(Form, start_year_2024_or_later?: true, start_year_2025_or_later?: false) }
let(:form) { instance_double(Form, start_year_2025_or_later?: false) }
it "has correct pages" do
expect(household_characteristics.pages.map(&:id)).to eq(
@ -36,7 +36,7 @@ RSpec.describe Form::Sales::Subsections::HouseholdSituation, type: :model do
end
context "when the start year is 2025" do
let(:form) { instance_double(Form, start_year_2024_or_later?: true, start_year_2025_or_later?: true) }
let(:form) { instance_double(Form, start_year_2025_or_later?: true) }
it "has correct pages" do
expect(household_characteristics.pages.map(&:id)).to eq(

Loading…
Cancel
Save