Browse Source

CLDC-3991: Update working situation answer options copy (#3040)

* CLDC-3991 Update working situation answer options to clarify full-time/part-time

* Update working situation copy unable to work

* Keep old copy pre 2025

* Update tests

* Fix flaky test, check regardless of order

* Update test

* Lint
main v0.5.9
Manny Dinssa 19 hours ago committed by GitHub
parent
commit
a2ee52a8f7
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 60
      app/models/form/lettings/questions/person_working_situation.rb
  2. 46
      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. 2
      spec/fixtures/files/sales_logs_csv_export_labels_25.csv
  7. 2
      spec/fixtures/files/sales_logs_csv_export_non_support_labels_25.csv
  8. 2
      spec/jobs/process_merge_request_job_spec.rb
  9. 4
      spec/models/form/lettings/pages/person_working_situation_spec.rb
  10. 12
      spec/models/form/lettings/questions/person_working_situation_spec.rb
  11. 30
      spec/models/form/sales/questions/buyer1_working_situation_spec.rb
  12. 31
      spec/models/form/sales/questions/buyer2_working_situation_spec.rb
  13. 29
      spec/models/form/sales/questions/person_working_situation_spec.rb

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

@ -10,25 +10,47 @@ class Form::Lettings::Questions::PersonWorkingSituation < ::Form::Question
end
def answer_options
{ "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" } }
if form.start_year_2025_or_later?
{ "1" => { "value" => "Full-time – 30 hours or more per week" },
"2" => { "value" => "Part-time – Less than 30 hours per week" },
"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 sickness 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" } }
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
def question_number

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

@ -4,23 +4,41 @@ class Form::Lettings::Questions::WorkingSituation1 < ::Form::Question
@id = "ecstat1"
@type = "radio"
@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]
end
ANSWER_OPTIONS = {
"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" },
}.freeze
def answer_options
if form.start_year_2025_or_later?
{
"1" => { "value" => "Full-time – 30 hours or more per week" },
"2" => { "value" => "Part-time – Less than 30 hours per week" },
"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 sickness or disability" },
"5" => { "value" => "Retired" },
"0" => { "value" => "Other" },
"divider" => { "value" => true },
"10" => { "value" => "Tenant 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" },
"0" => { "value" => "Other" },
"divider" => { "value" => true },
"10" => { "value" => "Tenant prefers not to say" },
}
end
end
QUESTION_NUMBER_FROM_YEAR = { 2023 => 37, 2024 => 36 }.freeze
end

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

@ -17,14 +17,14 @@ class Form::Sales::Questions::Buyer1WorkingSituation < ::Form::Question
def answer_options
if form.start_year_2025_or_later?
{
"1" => { "value" => "Full-time - 30 hours or more" },
"2" => { "value" => "Part-time - Less than 30 hours" },
"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" },
"5" => { "value" => "Retired" },
"6" => { "value" => "Not seeking work" },
"7" => { "value" => "Full-time student" },
"8" => { "value" => "Unable to work due to long term sick or disability" },
"8" => { "value" => "Unable to work because of long-term sickness or disability" },
"0" => { "value" => "Other" },
"10" => { "value" => "Buyer prefers not to say" },
}.freeze

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

@ -22,14 +22,14 @@ class Form::Sales::Questions::Buyer2WorkingSituation < ::Form::Question
def answer_options
if form.start_year_2025_or_later?
{
"1" => { "value" => "Full-time - 30 hours or more" },
"2" => { "value" => "Part-time - Less than 30 hours" },
"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" },
"5" => { "value" => "Retired" },
"6" => { "value" => "Not seeking work" },
"7" => { "value" => "Full-time student" },
"8" => { "value" => "Unable to work due to long term sick or disability" },
"8" => { "value" => "Unable to work because of long-term sickness or disability" },
"9" => { "value" => "Child under 16" },
"0" => { "value" => "Other" },
"10" => { "value" => "Buyer prefers not to say" },

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

@ -18,14 +18,14 @@ class Form::Sales::Questions::PersonWorkingSituation < ::Form::Question
def answer_options
if form.start_year_2025_or_later?
{
"1" => { "value" => "Full-time - 30 hours or more" },
"2" => { "value" => "Part-time - Less than 30 hours" },
"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" },
"5" => { "value" => "Retired" },
"6" => { "value" => "Not seeking work" },
"7" => { "value" => "Full-time student" },
"8" => { "value" => "Unable to work due to long term sick or disability" },
"8" => { "value" => "Unable to work because of long-term sickness or disability" },
"9" => {
"value" => "Child under 16",
"depends_on" => [

2
spec/fixtures/files/sales_logs_csv_export_labels_25.csv vendored

File diff suppressed because one or more lines are too long

2
spec/fixtures/files/sales_logs_csv_export_non_support_labels_25.csv vendored

File diff suppressed because one or more lines are too long

2
spec/jobs/process_merge_request_job_spec.rb

@ -31,7 +31,7 @@ describe ProcessMergeRequestJob do
let(:merge_request) { MergeRequest.create!(requesting_organisation: organisation, absorbing_organisation: organisation, merge_date: Time.zone.local(2022, 3, 3), existing_absorbing_organisation: false) }
it "calls the merge organisations service with correct arguments" do
expect(Merge::MergeOrganisationsService).to receive(:new).with(absorbing_organisation_id: organisation.id, merging_organisation_ids: [merging_organisation.id, other_merging_organisation.id], merge_date: Time.zone.local(2022, 3, 3), absorbing_organisation_active_from_merge_date: true)
expect(Merge::MergeOrganisationsService).to receive(:new).with(absorbing_organisation_id: organisation.id, merging_organisation_ids: match_array([merging_organisation.id, other_merging_organisation.id]), merge_date: Time.zone.local(2022, 3, 3), absorbing_organisation_active_from_merge_date: true)
job.perform(merge_request:)
expect(merge_request.reload.status).to eq("request_merged")

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

@ -7,6 +7,10 @@ RSpec.describe Form::Lettings::Pages::PersonWorkingSituation, type: :model do
let(:subsection) { instance_double(Form::Subsection, form: instance_double(Form, start_date: Time.zone.local(2024, 4, 1))) }
let(:person_index) { 2 }
before do
allow(subsection.form).to receive(:start_year_2025_or_later?).and_return(false)
end
it "has correct subsection" do
expect(page.subsection).to eq(subsection)
end

12
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:) }
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 }
before do
allow(page.subsection.form).to receive(:start_year_2025_or_later?).and_return(true)
end
it "has correct page" do
expect(question.page).to eq(page)
end
@ -21,15 +25,15 @@ RSpec.describe Form::Lettings::Questions::PersonWorkingSituation, type: :model d
it "has the correct answer_options" do
expect(question.answer_options).to eq("0" => { "value" => "Other" },
"1" => { "value" => "Full-time – 30 hours or more" },
"1" => { "value" => "Full-time – 30 hours or more per week" },
"10" => { "value" => "Person prefers not to say" },
"2" => { "value" => "Part-time – Less than 30 hours" },
"2" => { "value" => "Part-time – Less than 30 hours per week" },
"3" => { "value" => "In government training into work" },
"4" => { "value" => "Jobseeker" },
"5" => { "value" => "Retired" },
"6" => { "value" => "Not seeking work" },
"7" => { "value" => "Full-time student" },
"8" => { "value" => "Unable to work because of long term sick or disability" },
"8" => { "value" => "Unable to work because of long-term sickness or disability" },
"9" => {
"depends_on" => [
{ "age2_known" => 1 },

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
end
it "has the correct answer_options" do
expect(question.answer_options).to eq({
"1" => { "value" => "Full-time - 30 hours or more" },
"2" => { "value" => "Part-time - Less than 30 hours" },
"3" => { "value" => "In government training into work" },
"4" => { "value" => "Jobseeker" },
"6" => { "value" => "Not seeking work" },
"8" => { "value" => "Unable to work due to long term sick 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
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
expect(question.answer_options.keys).to eq(%w[1 2 3 4 5 6 7 8 0 10])
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
it "has the correct check_answers_card_number" do

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

@ -77,6 +77,37 @@ RSpec.describe Form::Sales::Questions::Buyer2WorkingSituation, type: :model 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])
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
it "has the correct check_answers_card_number" do

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

@ -35,10 +35,10 @@ RSpec.describe Form::Sales::Questions::PersonWorkingSituation, type: :model do
"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 } }] },
[{ "saledate" => { "operator" => "<", "operand" => Time.zone.local(2024, 4, 1) } },
{ "age2_known" => 1 },
{ "age2_known" => nil },
{ "age2" => { "operator" => "<", "operand" => 16 } }] },
})
end
@ -56,6 +56,27 @@ RSpec.describe Form::Sales::Questions::PersonWorkingSituation, type: :model 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])
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
context "when person 2" do

Loading…
Cancel
Save