Browse Source

Make working situation questions generic

pull/1254/head
Kat 3 years ago
parent
commit
2cb5bf3bf6
  1. 2
      app/models/form/lettings/pages/lead_tenant_working_situation.rb
  2. 13
      app/models/form/lettings/pages/person_2_working_situation.rb
  3. 13
      app/models/form/lettings/pages/person_3_working_situation.rb
  4. 13
      app/models/form/lettings/pages/person_4_working_situation.rb
  5. 13
      app/models/form/lettings/pages/person_5_working_situation.rb
  6. 13
      app/models/form/lettings/pages/person_6_working_situation.rb
  7. 13
      app/models/form/lettings/pages/person_7_working_situation.rb
  8. 13
      app/models/form/lettings/pages/person_8_working_situation.rb
  9. 14
      app/models/form/lettings/pages/person_working_situation.rb
  10. 14
      app/models/form/lettings/questions/ecstat2.rb
  11. 14
      app/models/form/lettings/questions/ecstat3.rb
  12. 14
      app/models/form/lettings/questions/ecstat4.rb
  13. 14
      app/models/form/lettings/questions/ecstat5.rb
  14. 14
      app/models/form/lettings/questions/ecstat6.rb
  15. 14
      app/models/form/lettings/questions/ecstat7.rb
  16. 14
      app/models/form/lettings/questions/ecstat8.rb
  17. 25
      app/models/form/lettings/questions/person_working_situation.rb
  18. 2
      app/models/form/lettings/questions/working_situation1.rb
  19. 14
      app/models/form/lettings/subsections/household_characteristics.rb
  20. 57
      spec/models/form/lettings/pages/person_working_situation_spec.rb
  21. 86
      spec/models/form/lettings/questions/person_working_situation_spec.rb

2
app/models/form/lettings/pages/lead_tenant_working_situation.rb

@ -8,6 +8,6 @@ class Form::Lettings::Pages::LeadTenantWorkingSituation < ::Form::Page
end end
def questions def questions
@questions ||= [Form::Lettings::Questions::Ecstat1.new(nil, nil, self)] @questions ||= [Form::Lettings::Questions::WorkingSituation1.new(nil, nil, self)]
end end
end end

13
app/models/form/lettings/pages/person_2_working_situation.rb

@ -1,13 +0,0 @@
class Form::Lettings::Pages::Person2WorkingSituation < ::Form::Page
def initialize(id, hsh, subsection)
super
@id = "person_2_working_situation"
@header = ""
@depends_on = [{ "details_known_2" => 0, "age2" => { "operator" => ">", "operand" => 15 } }, { "details_known_2" => 0, "age2" => nil }]
@description = ""
end
def questions
@questions ||= [Form::Lettings::Questions::Ecstat2.new(nil, nil, self)]
end
end

13
app/models/form/lettings/pages/person_3_working_situation.rb

@ -1,13 +0,0 @@
class Form::Lettings::Pages::Person3WorkingSituation < ::Form::Page
def initialize(id, hsh, subsection)
super
@id = "person_3_working_situation"
@header = ""
@depends_on = [{ "details_known_3" => 0, "age3" => { "operator" => ">", "operand" => 15 } }, { "details_known_3" => 0, "age3" => nil }]
@description = ""
end
def questions
@questions ||= [Form::Lettings::Questions::Ecstat3.new(nil, nil, self)]
end
end

13
app/models/form/lettings/pages/person_4_working_situation.rb

@ -1,13 +0,0 @@
class Form::Lettings::Pages::Person4WorkingSituation < ::Form::Page
def initialize(id, hsh, subsection)
super
@id = "person_4_working_situation"
@header = ""
@depends_on = [{ "details_known_4" => 0, "age4" => { "operator" => ">", "operand" => 15 } }, { "details_known_4" => 0, "age4" => nil }]
@description = ""
end
def questions
@questions ||= [Form::Lettings::Questions::Ecstat4.new(nil, nil, self)]
end
end

13
app/models/form/lettings/pages/person_5_working_situation.rb

@ -1,13 +0,0 @@
class Form::Lettings::Pages::Person5WorkingSituation < ::Form::Page
def initialize(id, hsh, subsection)
super
@id = "person_5_working_situation"
@header = ""
@depends_on = [{ "details_known_5" => 0, "age5" => { "operator" => ">", "operand" => 15 } }, { "details_known_5" => 0, "age5" => nil }]
@description = ""
end
def questions
@questions ||= [Form::Lettings::Questions::Ecstat5.new(nil, nil, self)]
end
end

13
app/models/form/lettings/pages/person_6_working_situation.rb

@ -1,13 +0,0 @@
class Form::Lettings::Pages::Person6WorkingSituation < ::Form::Page
def initialize(id, hsh, subsection)
super
@id = "person_6_working_situation"
@header = ""
@depends_on = [{ "details_known_6" => 0, "age6" => { "operator" => ">", "operand" => 15 } }, { "details_known_6" => 0, "age6" => nil }]
@description = ""
end
def questions
@questions ||= [Form::Lettings::Questions::Ecstat6.new(nil, nil, self)]
end
end

13
app/models/form/lettings/pages/person_7_working_situation.rb

@ -1,13 +0,0 @@
class Form::Lettings::Pages::Person7WorkingSituation < ::Form::Page
def initialize(id, hsh, subsection)
super
@id = "person_7_working_situation"
@header = ""
@depends_on = [{ "details_known_7" => 0, "age7" => { "operator" => ">", "operand" => 15 } }, { "details_known_7" => 0, "age7" => nil }]
@description = ""
end
def questions
@questions ||= [Form::Lettings::Questions::Ecstat7.new(nil, nil, self)]
end
end

13
app/models/form/lettings/pages/person_8_working_situation.rb

@ -1,13 +0,0 @@
class Form::Lettings::Pages::Person8WorkingSituation < ::Form::Page
def initialize(id, hsh, subsection)
super
@id = "person_8_working_situation"
@header = ""
@depends_on = [{ "details_known_8" => 0, "age8" => { "operator" => ">", "operand" => 15 } }, { "details_known_8" => 0, "age8" => nil }]
@description = ""
end
def questions
@questions ||= [Form::Lettings::Questions::Ecstat8.new(nil, nil, self)]
end
end

14
app/models/form/lettings/pages/person_working_situation.rb

@ -0,0 +1,14 @@
class Form::Lettings::Pages::PersonWorkingSituation < ::Form::Page
def initialize(id, hsh, subsection, person_index:)
super(id, hsh, subsection)
@id = "person_#{person_index}_working_situation"
@header = ""
@depends_on = [{ "details_known_#{person_index}" => 0, "age#{person_index}" => { "operator" => ">", "operand" => 15 } }, { "details_known_#{person_index}" => 0, "age#{person_index}" => nil }]
@description = ""
@person_index = person_index
end
def questions
@questions ||= [Form::Lettings::Questions::PersonWorkingSituation.new(nil, nil, self, person_index: @person_index)]
end
end

14
app/models/form/lettings/questions/ecstat2.rb

@ -1,14 +0,0 @@
class Form::Lettings::Questions::Ecstat2 < ::Form::Question
def initialize(id, hsh, page)
super
@id = "ecstat2"
@check_answer_label = "Person 2’s working situation"
@header = "Which of these best describes person 2’s working situation?"
@type = "radio"
@check_answers_card_number = 2
@hint_text = ""
@answer_options = ANSWER_OPTIONS
end
ANSWER_OPTIONS = { "2" => { "value" => "Part-time – Less than 30 hours" }, "1" => { "value" => "Full-time – 30 hours or more" }, "7" => { "value" => "Full-time student" }, "3" => { "value" => "In government training into work, such as New Deal" }, "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" => [{ "age2_known" => 1 }, { "age2" => { "operator" => "<", "operand" => 16 } }] }, "0" => { "value" => "Other" }, "divider" => { "value" => true }, "10" => { "value" => "Tenant prefers not to say" } }.freeze
end

14
app/models/form/lettings/questions/ecstat3.rb

@ -1,14 +0,0 @@
class Form::Lettings::Questions::Ecstat3 < ::Form::Question
def initialize(id, hsh, page)
super
@id = "ecstat3"
@check_answer_label = "Person 3’s working situation"
@header = "Which of these best describes person 3’s working situation?"
@type = "radio"
@check_answers_card_number = 3
@hint_text = ""
@answer_options = ANSWER_OPTIONS
end
ANSWER_OPTIONS = { "2" => { "value" => "Part-time – Less than 30 hours" }, "1" => { "value" => "Full-time – 30 hours or more" }, "7" => { "value" => "Full-time student" }, "3" => { "value" => "In government training into work, such as New Deal" }, "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" => [{ "age3_known" => 1 }, { "age3" => { "operator" => "<", "operand" => 16 } }] }, "0" => { "value" => "Other" }, "divider" => { "value" => true }, "10" => { "value" => "Tenant prefers not to say" } }.freeze
end

14
app/models/form/lettings/questions/ecstat4.rb

@ -1,14 +0,0 @@
class Form::Lettings::Questions::Ecstat4 < ::Form::Question
def initialize(id, hsh, page)
super
@id = "ecstat4"
@check_answer_label = "Person 4’s working situation"
@header = "Which of these best describes person 4’s working situation?"
@type = "radio"
@check_answers_card_number = 4
@hint_text = ""
@answer_options = ANSWER_OPTIONS
end
ANSWER_OPTIONS = { "2" => { "value" => "Part-time – Less than 30 hours" }, "1" => { "value" => "Full-time – 30 hours or more" }, "7" => { "value" => "Full-time student" }, "3" => { "value" => "In government training into work, such as New Deal" }, "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" => [{ "age4_known" => 1 }, { "age4" => { "operator" => "<", "operand" => 16 } }] }, "0" => { "value" => "Other" }, "divider" => { "value" => true }, "10" => { "value" => "Tenant prefers not to say" } }.freeze
end

14
app/models/form/lettings/questions/ecstat5.rb

@ -1,14 +0,0 @@
class Form::Lettings::Questions::Ecstat5 < ::Form::Question
def initialize(id, hsh, page)
super
@id = "ecstat5"
@check_answer_label = "Person 5’s working situation"
@header = "Which of these best describes person 5’s working situation?"
@type = "radio"
@check_answers_card_number = 5
@hint_text = ""
@answer_options = ANSWER_OPTIONS
end
ANSWER_OPTIONS = { "2" => { "value" => "Part-time – Less than 30 hours" }, "1" => { "value" => "Full-time – 30 hours or more" }, "7" => { "value" => "Full-time student" }, "3" => { "value" => "In government training into work, such as New Deal" }, "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" => [{ "age5_known" => 1 }, { "age5" => { "operator" => "<", "operand" => 16 } }] }, "0" => { "value" => "Other" }, "divider" => { "value" => true }, "10" => { "value" => "Tenant prefers not to say" } }.freeze
end

14
app/models/form/lettings/questions/ecstat6.rb

@ -1,14 +0,0 @@
class Form::Lettings::Questions::Ecstat6 < ::Form::Question
def initialize(id, hsh, page)
super
@id = "ecstat6"
@check_answer_label = "Person 6’s working situation"
@header = "Which of these best describes person 6’s working situation?"
@type = "radio"
@check_answers_card_number = 6
@hint_text = ""
@answer_options = ANSWER_OPTIONS
end
ANSWER_OPTIONS = { "2" => { "value" => "Part-time – Less than 30 hours" }, "1" => { "value" => "Full-time – 30 hours or more" }, "7" => { "value" => "Full-time student" }, "3" => { "value" => "In government training into work, such as New Deal" }, "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" => [{ "age6_known" => 1 }, { "age6" => { "operator" => "<", "operand" => 16 } }] }, "0" => { "value" => "Other" }, "divider" => { "value" => true }, "10" => { "value" => "Tenant prefers not to say" } }.freeze
end

14
app/models/form/lettings/questions/ecstat7.rb

@ -1,14 +0,0 @@
class Form::Lettings::Questions::Ecstat7 < ::Form::Question
def initialize(id, hsh, page)
super
@id = "ecstat7"
@check_answer_label = "Person 7’s working situation"
@header = "Which of these best describes person 7’s working situation?"
@type = "radio"
@check_answers_card_number = 7
@hint_text = ""
@answer_options = ANSWER_OPTIONS
end
ANSWER_OPTIONS = { "2" => { "value" => "Part-time – Less than 30 hours" }, "1" => { "value" => "Full-time – 30 hours or more" }, "7" => { "value" => "Full-time student" }, "3" => { "value" => "In government training into work, such as New Deal" }, "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" => [{ "age7_known" => 1 }, { "age7" => { "operator" => "<", "operand" => 16 } }] }, "0" => { "value" => "Other" }, "divider" => { "value" => true }, "10" => { "value" => "Tenant prefers not to say" } }.freeze
end

14
app/models/form/lettings/questions/ecstat8.rb

@ -1,14 +0,0 @@
class Form::Lettings::Questions::Ecstat8 < ::Form::Question
def initialize(id, hsh, page)
super
@id = "ecstat8"
@check_answer_label = "Person 8’s working situation"
@header = "Which of these best describes person 8’s working situation?"
@type = "radio"
@check_answers_card_number = 8
@hint_text = ""
@answer_options = ANSWER_OPTIONS
end
ANSWER_OPTIONS = { "2" => { "value" => "Part-time – Less than 30 hours" }, "1" => { "value" => "Full-time – 30 hours or more" }, "7" => { "value" => "Full-time student" }, "3" => { "value" => "In government training into work, such as New Deal" }, "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" => [{ "age8_known" => 1 }, { "age8" => { "operator" => "<", "operand" => 16 } }] }, "0" => { "value" => "Other" }, "divider" => { "value" => true }, "10" => { "value" => "Tenant prefers not to say" } }.freeze
end

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

@ -0,0 +1,25 @@
class Form::Lettings::Questions::PersonWorkingSituation < ::Form::Question
def initialize(id, hsh, page, person_index:)
super(id, hsh, page)
@id = "ecstat#{person_index}"
@check_answer_label = "Person #{person_index}’s working situation"
@header = "Which of these best describes person #{person_index}’s working situation?"
@type = "radio"
@check_answers_card_number = person_index
@hint_text = ""
@answer_options = ANSWER_OPTIONS
end
ANSWER_OPTIONS = { "2" => { "value" => "Part-time – Less than 30 hours" },
"1" => { "value" => "Full-time – 30 hours or more" },
"7" => { "value" => "Full-time student" },
"3" => { "value" => "In government training into work, such as New Deal" },
"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" => [{ "age2_known" => 1 }, { "age2" => { "operator" => "<", "operand" => 16 } }] },
"0" => { "value" => "Other" },
"divider" => { "value" => true },
"10" => { "value" => "Tenant prefers not to say" } }.freeze
end

2
app/models/form/lettings/questions/ecstat1.rb → app/models/form/lettings/questions/working_situation1.rb

@ -1,4 +1,4 @@
class Form::Lettings::Questions::Ecstat1 < ::Form::Question class Form::Lettings::Questions::WorkingSituation1 < ::Form::Question
def initialize(id, hsh, page) def initialize(id, hsh, page)
super super
@id = "ecstat1" @id = "ecstat1"

14
app/models/form/lettings/subsections/household_characteristics.rb

@ -35,7 +35,7 @@ class Form::Lettings::Subsections::HouseholdCharacteristics < ::Form::Subsection
Form::Lettings::Pages::PersonGenderIdentity.new(nil, nil, self, person_index: 2), Form::Lettings::Pages::PersonGenderIdentity.new(nil, nil, self, person_index: 2),
Form::Lettings::Pages::NoFemalesPregnantHouseholdPerson2ValueCheck.new(nil, nil, self), Form::Lettings::Pages::NoFemalesPregnantHouseholdPerson2ValueCheck.new(nil, nil, self),
Form::Lettings::Pages::FemalesInSoftAgeRangeInPregnantHouseholdPerson2ValueCheck.new(nil, nil, self), Form::Lettings::Pages::FemalesInSoftAgeRangeInPregnantHouseholdPerson2ValueCheck.new(nil, nil, self),
Form::Lettings::Pages::Person2WorkingSituation.new(nil, nil, self), Form::Lettings::Pages::PersonWorkingSituation.new(nil, nil, self, person_index: 2),
Form::Lettings::Pages::Person2UnderRetirementValueCheck.new(nil, nil, self), Form::Lettings::Pages::Person2UnderRetirementValueCheck.new(nil, nil, self),
Form::Lettings::Pages::Person2OverRetirementValueCheck.new(nil, nil, self), Form::Lettings::Pages::Person2OverRetirementValueCheck.new(nil, nil, self),
Form::Lettings::Pages::PersonKnown.new(nil, nil, self, person_index: 3), Form::Lettings::Pages::PersonKnown.new(nil, nil, self, person_index: 3),
@ -46,7 +46,7 @@ class Form::Lettings::Subsections::HouseholdCharacteristics < ::Form::Subsection
Form::Lettings::Pages::PersonGenderIdentity.new(nil, nil, self, person_index: 3), Form::Lettings::Pages::PersonGenderIdentity.new(nil, nil, self, person_index: 3),
Form::Lettings::Pages::NoFemalesPregnantHouseholdPerson3ValueCheck.new(nil, nil, self), Form::Lettings::Pages::NoFemalesPregnantHouseholdPerson3ValueCheck.new(nil, nil, self),
Form::Lettings::Pages::FemalesInSoftAgeRangeInPregnantHouseholdPerson3ValueCheck.new(nil, nil, self), Form::Lettings::Pages::FemalesInSoftAgeRangeInPregnantHouseholdPerson3ValueCheck.new(nil, nil, self),
Form::Lettings::Pages::Person3WorkingSituation.new(nil, nil, self), Form::Lettings::Pages::PersonWorkingSituation.new(nil, nil, self, person_index: 3),
Form::Lettings::Pages::Person3UnderRetirementValueCheck.new(nil, nil, self), Form::Lettings::Pages::Person3UnderRetirementValueCheck.new(nil, nil, self),
Form::Lettings::Pages::Person3OverRetirementValueCheck.new(nil, nil, self), Form::Lettings::Pages::Person3OverRetirementValueCheck.new(nil, nil, self),
Form::Lettings::Pages::PersonKnown.new(nil, nil, self, person_index: 4), Form::Lettings::Pages::PersonKnown.new(nil, nil, self, person_index: 4),
@ -57,7 +57,7 @@ class Form::Lettings::Subsections::HouseholdCharacteristics < ::Form::Subsection
Form::Lettings::Pages::PersonGenderIdentity.new(nil, nil, self, person_index: 4), Form::Lettings::Pages::PersonGenderIdentity.new(nil, nil, self, person_index: 4),
Form::Lettings::Pages::NoFemalesPregnantHouseholdPerson4ValueCheck.new(nil, nil, self), Form::Lettings::Pages::NoFemalesPregnantHouseholdPerson4ValueCheck.new(nil, nil, self),
Form::Lettings::Pages::FemalesInSoftAgeRangeInPregnantHouseholdPerson4ValueCheck.new(nil, nil, self), Form::Lettings::Pages::FemalesInSoftAgeRangeInPregnantHouseholdPerson4ValueCheck.new(nil, nil, self),
Form::Lettings::Pages::Person4WorkingSituation.new(nil, nil, self), Form::Lettings::Pages::PersonWorkingSituation.new(nil, nil, self, person_index: 4),
Form::Lettings::Pages::Person4UnderRetirementValueCheck.new(nil, nil, self), Form::Lettings::Pages::Person4UnderRetirementValueCheck.new(nil, nil, self),
Form::Lettings::Pages::Person4OverRetirementValueCheck.new(nil, nil, self), Form::Lettings::Pages::Person4OverRetirementValueCheck.new(nil, nil, self),
Form::Lettings::Pages::PersonKnown.new(nil, nil, self, person_index: 5), Form::Lettings::Pages::PersonKnown.new(nil, nil, self, person_index: 5),
@ -68,7 +68,7 @@ class Form::Lettings::Subsections::HouseholdCharacteristics < ::Form::Subsection
Form::Lettings::Pages::PersonGenderIdentity.new(nil, nil, self, person_index: 5), Form::Lettings::Pages::PersonGenderIdentity.new(nil, nil, self, person_index: 5),
Form::Lettings::Pages::NoFemalesPregnantHouseholdPerson5ValueCheck.new(nil, nil, self), Form::Lettings::Pages::NoFemalesPregnantHouseholdPerson5ValueCheck.new(nil, nil, self),
Form::Lettings::Pages::FemalesInSoftAgeRangeInPregnantHouseholdPerson5ValueCheck.new(nil, nil, self), Form::Lettings::Pages::FemalesInSoftAgeRangeInPregnantHouseholdPerson5ValueCheck.new(nil, nil, self),
Form::Lettings::Pages::Person5WorkingSituation.new(nil, nil, self), Form::Lettings::Pages::PersonWorkingSituation.new(nil, nil, self, person_index: 5),
Form::Lettings::Pages::Person5UnderRetirementValueCheck.new(nil, nil, self), Form::Lettings::Pages::Person5UnderRetirementValueCheck.new(nil, nil, self),
Form::Lettings::Pages::Person5OverRetirementValueCheck.new(nil, nil, self), Form::Lettings::Pages::Person5OverRetirementValueCheck.new(nil, nil, self),
Form::Lettings::Pages::PersonKnown.new(nil, nil, self, person_index: 6), Form::Lettings::Pages::PersonKnown.new(nil, nil, self, person_index: 6),
@ -79,7 +79,7 @@ class Form::Lettings::Subsections::HouseholdCharacteristics < ::Form::Subsection
Form::Lettings::Pages::PersonGenderIdentity.new(nil, nil, self, person_index: 6), Form::Lettings::Pages::PersonGenderIdentity.new(nil, nil, self, person_index: 6),
Form::Lettings::Pages::NoFemalesPregnantHouseholdPerson6ValueCheck.new(nil, nil, self), Form::Lettings::Pages::NoFemalesPregnantHouseholdPerson6ValueCheck.new(nil, nil, self),
Form::Lettings::Pages::FemalesInSoftAgeRangeInPregnantHouseholdPerson6ValueCheck.new(nil, nil, self), Form::Lettings::Pages::FemalesInSoftAgeRangeInPregnantHouseholdPerson6ValueCheck.new(nil, nil, self),
Form::Lettings::Pages::Person6WorkingSituation.new(nil, nil, self), Form::Lettings::Pages::PersonWorkingSituation.new(nil, nil, self, person_index: 6),
Form::Lettings::Pages::Person6UnderRetirementValueCheck.new(nil, nil, self), Form::Lettings::Pages::Person6UnderRetirementValueCheck.new(nil, nil, self),
Form::Lettings::Pages::Person6OverRetirementValueCheck.new(nil, nil, self), Form::Lettings::Pages::Person6OverRetirementValueCheck.new(nil, nil, self),
Form::Lettings::Pages::PersonKnown.new(nil, nil, self, person_index: 7), Form::Lettings::Pages::PersonKnown.new(nil, nil, self, person_index: 7),
@ -90,7 +90,7 @@ class Form::Lettings::Subsections::HouseholdCharacteristics < ::Form::Subsection
Form::Lettings::Pages::PersonGenderIdentity.new(nil, nil, self, person_index: 7), Form::Lettings::Pages::PersonGenderIdentity.new(nil, nil, self, person_index: 7),
Form::Lettings::Pages::NoFemalesPregnantHouseholdPerson7ValueCheck.new(nil, nil, self), Form::Lettings::Pages::NoFemalesPregnantHouseholdPerson7ValueCheck.new(nil, nil, self),
Form::Lettings::Pages::FemalesInSoftAgeRangeInPregnantHouseholdPerson7ValueCheck.new(nil, nil, self), Form::Lettings::Pages::FemalesInSoftAgeRangeInPregnantHouseholdPerson7ValueCheck.new(nil, nil, self),
Form::Lettings::Pages::Person7WorkingSituation.new(nil, nil, self), Form::Lettings::Pages::PersonWorkingSituation.new(nil, nil, self, person_index: 7),
Form::Lettings::Pages::Person7UnderRetirementValueCheck.new(nil, nil, self), Form::Lettings::Pages::Person7UnderRetirementValueCheck.new(nil, nil, self),
Form::Lettings::Pages::Person7OverRetirementValueCheck.new(nil, nil, self), Form::Lettings::Pages::Person7OverRetirementValueCheck.new(nil, nil, self),
Form::Lettings::Pages::PersonKnown.new(nil, nil, self, person_index: 8), Form::Lettings::Pages::PersonKnown.new(nil, nil, self, person_index: 8),
@ -101,7 +101,7 @@ class Form::Lettings::Subsections::HouseholdCharacteristics < ::Form::Subsection
Form::Lettings::Pages::PersonGenderIdentity.new(nil, nil, self, person_index: 8), Form::Lettings::Pages::PersonGenderIdentity.new(nil, nil, self, person_index: 8),
Form::Lettings::Pages::NoFemalesPregnantHouseholdPerson8ValueCheck.new(nil, nil, self), Form::Lettings::Pages::NoFemalesPregnantHouseholdPerson8ValueCheck.new(nil, nil, self),
Form::Lettings::Pages::FemalesInSoftAgeRangeInPregnantHouseholdPerson8ValueCheck.new(nil, nil, self), Form::Lettings::Pages::FemalesInSoftAgeRangeInPregnantHouseholdPerson8ValueCheck.new(nil, nil, self),
Form::Lettings::Pages::Person8WorkingSituation.new(nil, nil, self), Form::Lettings::Pages::PersonWorkingSituation.new(nil, nil, self, person_index: 8),
Form::Lettings::Pages::Person8UnderRetirementValueCheck.new(nil, nil, self), Form::Lettings::Pages::Person8UnderRetirementValueCheck.new(nil, nil, self),
Form::Lettings::Pages::Person8OverRetirementValueCheck.new(nil, nil, self)].compact Form::Lettings::Pages::Person8OverRetirementValueCheck.new(nil, nil, self)].compact
end end

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

@ -0,0 +1,57 @@
require "rails_helper"
RSpec.describe Form::Lettings::Pages::PersonWorkingSituation, type: :model do
subject(:page) { described_class.new(nil, page_definition, subsection, person_index:) }
let(:page_definition) { nil }
let(:subsection) { instance_double(Form::Subsection) }
let(:person_index) { 2 }
it "has correct subsection" do
expect(page.subsection).to eq(subsection)
end
it "has the correct header" do
expect(page.header).to eq("")
end
it "has the correct description" do
expect(page.description).to eq("")
end
context "with person 2" do
it "has correct questions" do
expect(page.questions.map(&:id)).to eq(%w[ecstat2])
end
it "has the correct id" do
expect(page.id).to eq("person_2_working_situation")
end
it "has correct depends_on" do
expect(page.depends_on).to eq(
[{ "age2" => { "operand" => 15, "operator" => ">" }, "details_known_2" => 0 },
{ "age2" => nil, "details_known_2" => 0 }],
)
end
end
context "with person 3" do
let(:person_index) { 3 }
it "has correct questions" do
expect(page.questions.map(&:id)).to eq(%w[ecstat3])
end
it "has the correct id" do
expect(page.id).to eq("person_3_working_situation")
end
it "has correct depends_on" do
expect(page.depends_on).to eq(
[{ "age3" => { "operand" => 15, "operator" => ">" }, "details_known_3" => 0 },
{ "age3" => nil, "details_known_3" => 0 }],
)
end
end
end

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

@ -0,0 +1,86 @@
require "rails_helper"
RSpec.describe Form::Lettings::Questions::PersonWorkingSituation, type: :model do
subject(:question) { described_class.new(nil, question_definition, page, person_index:) }
let(:question_definition) { nil }
let(:page) { instance_double(Form::Page) }
let(:person_index) { 2 }
it "has correct page" do
expect(question.page).to eq(page)
end
it "has the correct type" do
expect(question.type).to eq("radio")
end
it "is not marked as derived" do
expect(question.derived?).to be false
end
it "has the correct answer_options" do
expect(question.answer_options).to eq("0" => { "value" => "Other" },
"1" => { "value" => "Full-time – 30 hours or more" },
"10" => { "value" => "Tenant prefers not to say" },
"2" => { "value" => "Part-time – Less than 30 hours" },
"3" => { "value" => "In government training into work, such as New Deal" },
"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" },
"9" => { "depends_on" => [{ "age2_known" => 1 }, { "age2" => { "operand" => 16, "operator" => "<" } }], "value" => "Child under 16" },
"divider" => { "value" => true })
end
it "has the correct hint" do
expect(question.hint_text).to eq("")
end
it "has correct conditional for" do
expect(question.conditional_for).to be nil
end
it "has the correct hidden_in_check_answers" do
expect(question.hidden_in_check_answers).to be nil
end
context "with person 2" do
it "has the correct id" do
expect(question.id).to eq("ecstat2")
end
it "has the correct header" do
expect(question.header).to eq("Which of these best describes person 2’s working situation?")
end
it "has the correct check_answers_card_number" do
expect(question.check_answers_card_number).to eq(2)
end
it "has the correct check_answer_label" do
expect(question.check_answer_label).to eq("Person 2’s working situation")
end
end
context "with person 3" do
let(:person_index) { 3 }
it "has the correct id" do
expect(question.id).to eq("ecstat3")
end
it "has the correct header" do
expect(question.header).to eq("Which of these best describes person 3’s working situation?")
end
it "has the correct check_answers_card_number" do
expect(question.check_answers_card_number).to eq(3)
end
it "has the correct check_answer_label" do
expect(question.check_answer_label).to eq("Person 3’s working situation")
end
end
end
Loading…
Cancel
Save