Browse Source

CLDC-4402: model questions

CLDC-4402-audit-start-year-2024-or-later-usage
samyou-softwire 7 days ago
parent
commit
acd763ada1
  1. 6
      spec/models/form/lettings/questions/joint_spec.rb
  2. 26
      spec/models/form/lettings/questions/la_spec.rb
  3. 13
      spec/models/form/lettings/questions/tenancy_length_spec.rb
  4. 13
      spec/models/form/lettings/questions/tenancy_other_spec.rb
  5. 47
      spec/models/form/lettings/questions/waityear_spec.rb

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

@ -1,13 +1,15 @@
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(page).to receive(:subsection).and_return(subsection)
@ -40,6 +42,6 @@ RSpec.describe Form::Lettings::Questions::Joint, type: :model do
end
it "has the correct question number" do
expect(question.question_number).to eq(26)
expect(question.question_number).to eq(25)
end
end

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

@ -1,13 +1,19 @@
require "rails_helper"
RSpec.describe Form::Lettings::Questions::La, type: :model do
include CollectionTimeHelper
subject(:question) { described_class.new(question_id, question_definition, page) }
let(:question_id) { nil }
let(:question_definition) { nil }
let(:subsection) { instance_double(Form::Subsection, form: instance_double(Form, start_date:)) }
let(:subsection) { instance_double(Form::Subsection) }
let(:form) { instance_double(Form, start_date: current_collection_start_date) }
let(:page) { instance_double(Form::Page, subsection:) }
let(:start_date) { Time.utc(2023, 4, 1) }
before do
allow(subsection).to receive(:form).and_return(form)
end
it "has the correct answer_options" do
expect(question.answer_options).to eq({
@ -69,6 +75,12 @@ RSpec.describe Form::Lettings::Questions::La, type: :model do
"E06000058" => "Bournemouth, Christchurch and Poole",
"E06000059" => "Dorset",
"E06000060" => "Buckinghamshire",
"E06000061" => "North Northamptonshire",
"E06000062" => "West Northamptonshire",
"E06000063" => "Cumberland",
"E06000064" => "Westmorland and Furness",
"E06000065" => "North Yorkshire",
"E06000066" => "Somerset",
"E07000008" => "Cambridge",
"E07000009" => "East Cambridgeshire",
"E07000010" => "Fenland",
@ -175,8 +187,6 @@ RSpec.describe Form::Lettings::Questions::La, type: :model do
"E07000147" => "North Norfolk",
"E07000148" => "Norwich",
"E07000149" => "South Norfolk",
"E06000061" => "North Northamptonshire",
"E06000062" => "West Northamptonshire",
"E07000170" => "Ashfield",
"E07000171" => "Bassetlaw",
"E07000172" => "Broxtowe",
@ -250,10 +260,8 @@ RSpec.describe Form::Lettings::Questions::La, type: :model do
"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",
@ -263,7 +271,6 @@ RSpec.describe Form::Lettings::Questions::La, type: :model do
"E08000027" => "Dudley",
"E08000028" => "Sandwell",
"E08000029" => "Solihull",
"E06000066" => "Somerset",
"E08000030" => "Walsall",
"E08000031" => "Wolverhampton",
"E08000032" => "Bradford",
@ -272,6 +279,8 @@ RSpec.describe Form::Lettings::Questions::La, type: :model do
"E08000035" => "Leeds",
"E08000036" => "Wakefield",
"E08000037" => "Gateshead",
"E08000038" => "Barnsley",
"E08000039" => "Sheffield",
"E09000001" => "City of London",
"E09000002" => "Barking and Dagenham",
"E09000003" => "Barnet",
@ -280,7 +289,6 @@ RSpec.describe Form::Lettings::Questions::La, type: :model do
"E09000006" => "Bromley",
"E09000007" => "Camden",
"E09000008" => "Croydon",
"E06000063" => "Cumberland",
"E09000009" => "Ealing",
"E09000010" => "Enfield",
"E09000011" => "Greenwich",
@ -306,8 +314,6 @@ RSpec.describe Form::Lettings::Questions::La, type: :model do
"E09000031" => "Waltham Forest",
"E09000032" => "Wandsworth",
"E09000033" => "Westminster",
"E06000064" => "Westmorland and Furness",
"E06000065" => "North Yorkshire",
})
end

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

@ -1,10 +1,17 @@
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(:subsection) { instance_double(Form::Subsection) }
let(:form) { instance_double(Form, start_date: current_collection_start_date) }
let(:page) { instance_double(Form::Page, subsection:, id: "tenancy_length") }
before do
allow(subsection).to receive(:form).and_return(form)
end
it "has correct page" do
expect(question.page).to eq(page)
@ -32,6 +39,6 @@ RSpec.describe Form::Lettings::Questions::TenancyLength, type: :model do
end
it "has the correct question number" do
expect(question.question_number).to eq(29)
expect(question.question_number).to eq(28)
end
end

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

@ -1,10 +1,17 @@
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(:subsection) { instance_double(Form::Subsection) }
let(:form) { instance_double(Form, start_date: current_collection_start_date) }
let(:page) { instance_double(Form::Page, subsection:, id: "tenancy_type") }
before do
allow(subsection).to receive(:form).and_return(form)
end
it "has correct page" do
expect(question.page).to eq(page)
@ -23,6 +30,6 @@ RSpec.describe Form::Lettings::Questions::TenancyOther, type: :model do
end
it "has the correct question number" do
expect(question.question_number).to eq(28)
expect(question.question_number).to eq(27)
end
end

47
spec/models/form/lettings/questions/waityear_spec.rb

@ -44,39 +44,22 @@ RSpec.describe Form::Lettings::Questions::Waityear, type: :model do
expect(question.check_answers_card_number).to eq(0)
end
describe "before 2025" do
it "has the correct answer_options" do
expect(question.answer_options).to eq({
"2" => { "value" => "Less than 1 year" },
"7" => { "value" => "1 year but under 2 years" },
"8" => { "value" => "2 years but under 3 years" },
"9" => { "value" => "3 years but under 4 years" },
"10" => { "value" => "4 years but under 5 years" },
"5" => { "value" => "5 years or more" },
"divider" => { "value" => true },
"6" => { "value" => "Don’t know" },
})
end
before do
allow(form).to receive(:start_year_2025_or_later?).and_return(true)
end
context "with 2025/26 form" do
before do
allow(form).to receive(:start_year_2025_or_later?).and_return(true)
end
it "has the correct answer_options" do
expect(question.answer_options).to eq({
"13" => { "value" => "Household not on the housing register (or waiting list) in this area" },
"2" => { "value" => "Under 1 year" },
"7" => { "value" => "1 year but under 2 years" },
"8" => { "value" => "2 years but under 3 years" },
"9" => { "value" => "3 years but under 4 years" },
"10" => { "value" => "4 years but under 5 years" },
"11" => { "value" => "5 years but under 10 years" },
"12" => { "value" => "10 years or more" },
"divider" => { "value" => true },
"6" => { "value" => "Don’t know" },
})
end
it "has the correct answer_options" do
expect(question.answer_options).to eq({
"13" => { "value" => "Household not on the housing register (or waiting list) in this area" },
"2" => { "value" => "Under 1 year" },
"7" => { "value" => "1 year but under 2 years" },
"8" => { "value" => "2 years but under 3 years" },
"9" => { "value" => "3 years but under 4 years" },
"10" => { "value" => "4 years but under 5 years" },
"11" => { "value" => "5 years but under 10 years" },
"12" => { "value" => "10 years or more" },
"divider" => { "value" => true },
"6" => { "value" => "Don’t know" },
})
end
end

Loading…
Cancel
Save