Browse Source

Keep old copy pre 2025

pull/3040/head
Manny Dinssa 1 month ago
parent
commit
807a331ba3
  1. 22
      app/models/form/lettings/questions/person_working_situation.rb
  2. 24
      app/models/form/lettings/questions/working_situation1.rb
  3. 6
      app/models/form/sales/questions/buyer1_working_situation.rb
  4. 6
      app/models/form/sales/questions/buyer2_working_situation.rb
  5. 6
      app/models/form/sales/questions/person_working_situation.rb
  6. 6
      spec/models/form/lettings/questions/person_working_situation_spec.rb
  7. 30
      spec/models/form/sales/questions/buyer1_working_situation_spec.rb
  8. 43
      spec/models/form/sales/questions/buyer2_working_situation_spec.rb
  9. 27
      spec/models/form/sales/questions/person_working_situation_spec.rb

22
app/models/form/lettings/questions/person_working_situation.rb

@ -10,6 +10,7 @@ class Form::Lettings::Questions::PersonWorkingSituation < ::Form::Question
end end
def answer_options def answer_options
if form.start_year_2025_or_later?
{ "1" => { "value" => "Full-time – 30 hours or more per week" }, { "1" => { "value" => "Full-time – 30 hours or more per week" },
"2" => { "value" => "Part-time – Less than 30 hours per week" }, "2" => { "value" => "Part-time – Less than 30 hours per week" },
"7" => { "value" => "Full-time student" }, "7" => { "value" => "Full-time student" },
@ -29,6 +30,27 @@ class Form::Lettings::Questions::PersonWorkingSituation < ::Form::Question
"0" => { "value" => "Other" }, "0" => { "value" => "Other" },
"divider" => { "value" => true }, "divider" => { "value" => true },
"10" => { "value" => "Person prefers not to say" } } "10" => { "value" => "Person prefers not to say" } }
else
{ "1" => { "value" => "Full-time – 30 hours or more" },
"2" => { "value" => "Part-time – Less than 30 hours" },
"7" => { "value" => "Full-time student" },
"3" => { "value" => "In government training into work" },
"4" => { "value" => "Jobseeker" },
"6" => { "value" => "Not seeking work" },
"8" => { "value" => "Unable to work because of long term sick or disability" },
"5" => { "value" => "Retired" },
"9" => {
"value" => "Child under 16",
"depends_on" => [
{ "age#{@person_index}_known" => 1 },
{ "age#{@person_index}_known" => nil },
{ "age#{@person_index}" => { "operator" => "<", "operand" => 16 } },
],
},
"0" => { "value" => "Other" },
"divider" => { "value" => true },
"10" => { "value" => "Person prefers not to say" } }
end
end end
def question_number def question_number

24
app/models/form/lettings/questions/working_situation1.rb

@ -4,11 +4,13 @@ class Form::Lettings::Questions::WorkingSituation1 < ::Form::Question
@id = "ecstat1" @id = "ecstat1"
@type = "radio" @type = "radio"
@check_answers_card_number = 1 @check_answers_card_number = 1
@answer_options = ANSWER_OPTIONS @answer_options = answer_options
@question_number = QUESTION_NUMBER_FROM_YEAR[form.start_date.year] || QUESTION_NUMBER_FROM_YEAR[QUESTION_NUMBER_FROM_YEAR.keys.max] @question_number = QUESTION_NUMBER_FROM_YEAR[form.start_date.year] || QUESTION_NUMBER_FROM_YEAR[QUESTION_NUMBER_FROM_YEAR.keys.max]
end end
ANSWER_OPTIONS = { def answer_options
if form.start_year_2025_or_later?
{
"1" => { "value" => "Full-time – 30 hours or more per week" }, "1" => { "value" => "Full-time – 30 hours or more per week" },
"2" => { "value" => "Part-time – Less than 30 hours per week" }, "2" => { "value" => "Part-time – Less than 30 hours per week" },
"7" => { "value" => "Full-time student" }, "7" => { "value" => "Full-time student" },
@ -20,7 +22,23 @@ class Form::Lettings::Questions::WorkingSituation1 < ::Form::Question
"0" => { "value" => "Other" }, "0" => { "value" => "Other" },
"divider" => { "value" => true }, "divider" => { "value" => true },
"10" => { "value" => "Tenant prefers not to say" }, "10" => { "value" => "Tenant prefers not to say" },
}.freeze }
else
{
"1" => { "value" => "Full-time – 30 hours or more" },
"2" => { "value" => "Part-time – Less than 30 hours" },
"7" => { "value" => "Full-time student" },
"3" => { "value" => "In government training into work" },
"4" => { "value" => "Jobseeker" },
"6" => { "value" => "Not seeking work" },
"8" => { "value" => "Unable to work because of long term sick or disability" },
"5" => { "value" => "Retired" },
"0" => { "value" => "Other" },
"divider" => { "value" => true },
"10" => { "value" => "Tenant prefers not to say" },
}
end
end
QUESTION_NUMBER_FROM_YEAR = { 2023 => 37, 2024 => 36 }.freeze QUESTION_NUMBER_FROM_YEAR = { 2023 => 37, 2024 => 36 }.freeze
end end

6
app/models/form/sales/questions/buyer1_working_situation.rb

@ -30,12 +30,12 @@ class Form::Sales::Questions::Buyer1WorkingSituation < ::Form::Question
}.freeze }.freeze
else else
{ {
"1" => { "value" => "Full-time – 30 hours or more per week" }, "1" => { "value" => "Full-time - 30 hours or more" },
"2" => { "value" => "Part-time – Less than 30 hours per week" }, "2" => { "value" => "Part-time - Less than 30 hours" },
"3" => { "value" => "In government training into work" }, "3" => { "value" => "In government training into work" },
"4" => { "value" => "Jobseeker" }, "4" => { "value" => "Jobseeker" },
"6" => { "value" => "Not seeking work" }, "6" => { "value" => "Not seeking work" },
"8" => { "value" => "Unable to work because of long-term sickness or disability" }, "8" => { "value" => "Unable to work due to long term sick or disability" },
"5" => { "value" => "Retired" }, "5" => { "value" => "Retired" },
"0" => { "value" => "Other" }, "0" => { "value" => "Other" },
"10" => { "value" => "Buyer prefers not to say" }, "10" => { "value" => "Buyer prefers not to say" },

6
app/models/form/sales/questions/buyer2_working_situation.rb

@ -36,12 +36,12 @@ class Form::Sales::Questions::Buyer2WorkingSituation < ::Form::Question
}.freeze }.freeze
else else
{ {
"1" => { "value" => "Full-time – 30 hours or more per week" }, "1" => { "value" => "Full-time - 30 hours or more" },
"2" => { "value" => "Part-time – Less than 30 hours per week" }, "2" => { "value" => "Part-time - Less than 30 hours" },
"3" => { "value" => "In government training into work" }, "3" => { "value" => "In government training into work" },
"4" => { "value" => "Jobseeker" }, "4" => { "value" => "Jobseeker" },
"6" => { "value" => "Not seeking work" }, "6" => { "value" => "Not seeking work" },
"8" => { "value" => "Unable to work because of long-term sickness or disability" }, "8" => { "value" => "Unable to work due to long term sick or disability" },
"5" => { "value" => "Retired" }, "5" => { "value" => "Retired" },
"0" => { "value" => "Other" }, "0" => { "value" => "Other" },
"10" => { "value" => "Buyer prefers not to say" }, "10" => { "value" => "Buyer prefers not to say" },

6
app/models/form/sales/questions/person_working_situation.rb

@ -40,12 +40,12 @@ class Form::Sales::Questions::PersonWorkingSituation < ::Form::Question
} }
else else
{ {
"1" => { "value" => "Full-time – 30 hours or more per week" }, "1" => { "value" => "Full-time - 30 hours or more" },
"2" => { "value" => "Part-time – Less than 30 hours per week" }, "2" => { "value" => "Part-time - Less than 30 hours" },
"3" => { "value" => "In government training into work" }, "3" => { "value" => "In government training into work" },
"4" => { "value" => "Jobseeker" }, "4" => { "value" => "Jobseeker" },
"6" => { "value" => "Not seeking work" }, "6" => { "value" => "Not seeking work" },
"8" => { "value" => "Unable to work because of long-term sickness or disability" }, "8" => { "value" => "Unable to work due to long term sick or disability" },
"5" => { "value" => "Retired" }, "5" => { "value" => "Retired" },
"0" => { "value" => "Other" }, "0" => { "value" => "Other" },
"10" => { "value" => "Person prefers not to say" }, "10" => { "value" => "Person prefers not to say" },

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

@ -4,9 +4,13 @@ RSpec.describe Form::Lettings::Questions::PersonWorkingSituation, type: :model d
subject(:question) { described_class.new(nil, question_definition, page, person_index:) } subject(:question) { described_class.new(nil, question_definition, page, person_index:) }
let(:question_definition) { nil } let(:question_definition) { nil }
let(:page) { instance_double(Form::Page, subsection: instance_double(Form::Subsection, form: instance_double(Form, start_date: Time.zone.local(2023, 4, 4)))) } let(:page) { instance_double(Form::Page, subsection: instance_double(Form::Subsection, form: instance_double(Form, start_date: Time.zone.local(2025, 4, 4)))) }
let(:person_index) { 2 } let(:person_index) { 2 }
before do
allow(page.subsection.form).to receive(:start_year_2025_or_later?).and_return(true)
end
it "has correct page" do it "has correct page" do
expect(question.page).to eq(page) expect(question.page).to eq(page)
end end

30
spec/models/form/sales/questions/buyer1_working_situation_spec.rb

@ -24,21 +24,6 @@ RSpec.describe Form::Sales::Questions::Buyer1WorkingSituation, type: :model do
expect(question.derived?(nil)).to be false expect(question.derived?(nil)).to be false
end end
it "has the correct answer_options" do
expect(question.answer_options).to eq({
"1" => { "value" => "Full-time – 30 hours or more per week" },
"2" => { "value" => "Part-time – Less than 30 hours per week" },
"3" => { "value" => "In government training into work" },
"4" => { "value" => "Jobseeker" },
"6" => { "value" => "Not seeking work" },
"8" => { "value" => "Unable to work because of long-term sickness or disability" },
"5" => { "value" => "Retired" },
"0" => { "value" => "Other" },
"10" => { "value" => "Buyer prefers not to say" },
"7" => { "value" => "Full-time student" },
})
end
context "with start year before 2025" do context "with start year before 2025" do
let(:form) { instance_double(Form, start_date: Time.zone.local(2024, 4, 1), start_year_2025_or_later?: false) } let(:form) { instance_double(Form, start_date: Time.zone.local(2024, 4, 1), start_year_2025_or_later?: false) }
@ -53,6 +38,21 @@ RSpec.describe Form::Sales::Questions::Buyer1WorkingSituation, type: :model do
it "uses the new ordering for answer options" do it "uses the new ordering for answer options" do
expect(question.answer_options.keys).to eq(%w[1 2 3 4 5 6 7 8 0 10]) expect(question.answer_options.keys).to eq(%w[1 2 3 4 5 6 7 8 0 10])
end end
it "has the correct answer_options" do
expect(question.answer_options).to eq({
"1" => { "value" => "Full-time – 30 hours or more per week" },
"2" => { "value" => "Part-time – Less than 30 hours per week" },
"3" => { "value" => "In government training into work" },
"4" => { "value" => "Jobseeker" },
"6" => { "value" => "Not seeking work" },
"8" => { "value" => "Unable to work because of long-term sickness or disability" },
"5" => { "value" => "Retired" },
"0" => { "value" => "Other" },
"10" => { "value" => "Buyer prefers not to say" },
"7" => { "value" => "Full-time student" },
})
end
end end
it "has the correct check_answers_card_number" do it "has the correct check_answers_card_number" do

43
spec/models/form/sales/questions/buyer2_working_situation_spec.rb

@ -26,12 +26,12 @@ RSpec.describe Form::Sales::Questions::Buyer2WorkingSituation, type: :model do
it "has the correct answer_options" do it "has the correct answer_options" do
expect(question.answer_options).to eq({ expect(question.answer_options).to eq({
"1" => { "value" => "Full-time – 30 hours or more per week" }, "1" => { "value" => "Full-time - 30 hours or more" },
"2" => { "value" => "Part-time – Less than 30 hours per week" }, "2" => { "value" => "Part-time - Less than 30 hours" },
"3" => { "value" => "In government training into work" }, "3" => { "value" => "In government training into work" },
"4" => { "value" => "Jobseeker" }, "4" => { "value" => "Jobseeker" },
"6" => { "value" => "Not seeking work" }, "6" => { "value" => "Not seeking work" },
"8" => { "value" => "Unable to work because of long-term sickness or disability" }, "8" => { "value" => "Unable to work due to long term sick or disability" },
"5" => { "value" => "Retired" }, "5" => { "value" => "Retired" },
"0" => { "value" => "Other" }, "0" => { "value" => "Other" },
"10" => { "value" => "Buyer prefers not to say" }, "10" => { "value" => "Buyer prefers not to say" },
@ -42,12 +42,12 @@ RSpec.describe Form::Sales::Questions::Buyer2WorkingSituation, type: :model do
it "has the correct displayed_answer_options" do it "has the correct displayed_answer_options" do
expect(question.displayed_answer_options(nil)).to eq({ expect(question.displayed_answer_options(nil)).to eq({
"1" => { "value" => "Full-time – 30 hours or more per week" }, "1" => { "value" => "Full-time - 30 hours or more" },
"2" => { "value" => "Part-time – Less than 30 hours per week" }, "2" => { "value" => "Part-time - Less than 30 hours" },
"3" => { "value" => "In government training into work" }, "3" => { "value" => "In government training into work" },
"4" => { "value" => "Jobseeker" }, "4" => { "value" => "Jobseeker" },
"6" => { "value" => "Not seeking work" }, "6" => { "value" => "Not seeking work" },
"8" => { "value" => "Unable to work because of long-term sickness or disability" }, "8" => { "value" => "Unable to work due to long term sick or disability" },
"5" => { "value" => "Retired" }, "5" => { "value" => "Retired" },
"0" => { "value" => "Other" }, "0" => { "value" => "Other" },
"10" => { "value" => "Buyer prefers not to say" }, "10" => { "value" => "Buyer prefers not to say" },
@ -77,6 +77,37 @@ RSpec.describe Form::Sales::Questions::Buyer2WorkingSituation, type: :model do
it "uses the new ordering for displayed answer options" do it "uses the new ordering for displayed answer options" do
expect(question.displayed_answer_options(nil).keys).to eq(%w[1 2 3 4 5 6 7 8 0 10]) expect(question.displayed_answer_options(nil).keys).to eq(%w[1 2 3 4 5 6 7 8 0 10])
end end
it "has the correct answer_options" do
expect(question.answer_options).to eq({
"1" => { "value" => "Full-time – 30 hours or more per week" },
"2" => { "value" => "Part-time – Less than 30 hours per week" },
"3" => { "value" => "In government training into work" },
"4" => { "value" => "Jobseeker" },
"6" => { "value" => "Not seeking work" },
"8" => { "value" => "Unable to work because of long-term sickness or disability" },
"5" => { "value" => "Retired" },
"0" => { "value" => "Other" },
"10" => { "value" => "Buyer prefers not to say" },
"7" => { "value" => "Full-time student" },
"9" => { "value" => "Child under 16" },
})
end
it "has the correct displayed_answer_options" do
expect(question.displayed_answer_options(nil)).to eq({
"1" => { "value" => "Full-time – 30 hours or more per week" },
"2" => { "value" => "Part-time – Less than 30 hours per week" },
"3" => { "value" => "In government training into work" },
"4" => { "value" => "Jobseeker" },
"6" => { "value" => "Not seeking work" },
"8" => { "value" => "Unable to work because of long-term sickness or disability" },
"5" => { "value" => "Retired" },
"0" => { "value" => "Other" },
"10" => { "value" => "Buyer prefers not to say" },
"7" => { "value" => "Full-time student" },
})
end
end end
it "has the correct check_answers_card_number" do it "has the correct check_answers_card_number" do

27
spec/models/form/sales/questions/person_working_situation_spec.rb

@ -23,12 +23,12 @@ RSpec.describe Form::Sales::Questions::PersonWorkingSituation, type: :model do
it "has the correct answer_options" do it "has the correct answer_options" do
expect(question.answer_options).to eq({ expect(question.answer_options).to eq({
"1" => { "value" => "Full-time – 30 hours or more per week" }, "1" => { "value" => "Full-time - 30 hours or more" },
"2" => { "value" => "Part-time – Less than 30 hours per week" }, "2" => { "value" => "Part-time - Less than 30 hours" },
"3" => { "value" => "In government training into work" }, "3" => { "value" => "In government training into work" },
"4" => { "value" => "Jobseeker" }, "4" => { "value" => "Jobseeker" },
"6" => { "value" => "Not seeking work" }, "6" => { "value" => "Not seeking work" },
"8" => { "value" => "Unable to work because of long-term sickness or disability" }, "8" => { "value" => "Unable to work due to long term sick or disability" },
"5" => { "value" => "Retired" }, "5" => { "value" => "Retired" },
"0" => { "value" => "Other" }, "0" => { "value" => "Other" },
"10" => { "value" => "Person prefers not to say" }, "10" => { "value" => "Person prefers not to say" },
@ -56,6 +56,27 @@ RSpec.describe Form::Sales::Questions::PersonWorkingSituation, type: :model do
it "uses the new ordering for answer options" do it "uses the new ordering for answer options" do
expect(question.answer_options.keys).to eq(%w[1 2 3 4 5 6 7 8 9 0 10]) expect(question.answer_options.keys).to eq(%w[1 2 3 4 5 6 7 8 9 0 10])
end end
it "has the correct answer_options" do
expect(question.answer_options).to eq({
"1" => { "value" => "Full-time – 30 hours or more per week" },
"2" => { "value" => "Part-time – Less than 30 hours per week" },
"3" => { "value" => "In government training into work" },
"4" => { "value" => "Jobseeker" },
"6" => { "value" => "Not seeking work" },
"8" => { "value" => "Unable to work because of long-term sickness or disability" },
"5" => { "value" => "Retired" },
"0" => { "value" => "Other" },
"10" => { "value" => "Person prefers not to say" },
"7" => { "value" => "Full-time student" },
"9" => { "value" => "Child under 16",
"depends_on" =>
[{ "saledate" => { "operator" => "<", "operand" => Time.zone.local(2024, 4, 1) } },
{ "age2_known" => 1 },
{ "age2_known" => nil },
{ "age2" => { "operator" => "<", "operand" => 16 } }] },
})
end
end end
context "when person 2" do context "when person 2" do

Loading…
Cancel
Save