Browse Source

Make person gender identity questions generic

pull/1254/head
Kat 3 years ago
parent
commit
6b4747b89b
  1. 2
      app/models/form/lettings/pages/lead_tenant_gender_identity.rb
  2. 13
      app/models/form/lettings/pages/person_2_gender_identity.rb
  3. 13
      app/models/form/lettings/pages/person_3_gender_identity.rb
  4. 13
      app/models/form/lettings/pages/person_4_gender_identity.rb
  5. 13
      app/models/form/lettings/pages/person_5_gender_identity.rb
  6. 13
      app/models/form/lettings/pages/person_6_gender_identity.rb
  7. 13
      app/models/form/lettings/pages/person_7_gender_identity.rb
  8. 13
      app/models/form/lettings/pages/person_8_gender_identity.rb
  9. 14
      app/models/form/lettings/pages/person_gender_identity.rb
  10. 2
      app/models/form/lettings/questions/gender_identity1.rb
  11. 14
      app/models/form/lettings/questions/person_gender_identity.rb
  12. 14
      app/models/form/lettings/questions/sex2.rb
  13. 14
      app/models/form/lettings/questions/sex3.rb
  14. 14
      app/models/form/lettings/questions/sex4.rb
  15. 14
      app/models/form/lettings/questions/sex5.rb
  16. 14
      app/models/form/lettings/questions/sex6.rb
  17. 14
      app/models/form/lettings/questions/sex7.rb
  18. 14
      app/models/form/lettings/questions/sex8.rb
  19. 14
      app/models/form/lettings/subsections/household_characteristics.rb
  20. 55
      spec/models/form/lettings/pages/person_gender_identity_spec.rb
  21. 63
      spec/models/form/lettings/questions/person_gender_identity_spec.rb

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

2
app/models/form/lettings/questions/sex1.rb → app/models/form/lettings/questions/gender_identity1.rb

@ -1,4 +1,4 @@
class Form::Lettings::Questions::Sex1 < ::Form::Question
class Form::Lettings::Questions::GenderIdentity1 < ::Form::Question
def initialize(id, hsh, page)
super
@id = "sex1"

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

@ -0,0 +1,14 @@
class Form::Lettings::Questions::PersonGenderIdentity < ::Form::Question
def initialize(id, hsh, page, person_index:)
super(id, hsh, page)
@id = "sex#{person_index}"
@check_answer_label = "Person #{person_index}’s gender identity"
@header = "Which of these best describes person #{person_index}’s gender identity?"
@type = "radio"
@check_answers_card_number = person_index
@hint_text = ""
@answer_options = ANSWER_OPTIONS
end
ANSWER_OPTIONS = { "F" => { "value" => "Female" }, "M" => { "value" => "Male" }, "X" => { "value" => "Non-binary" }, "divider" => { "value" => true }, "R" => { "value" => "Person prefers not to say" } }.freeze
end

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

@ -1,14 +0,0 @@
class Form::Lettings::Questions::Sex2 < ::Form::Question
def initialize(id, hsh, page)
super
@id = "sex2"
@check_answer_label = "Person 2’s gender identity"
@header = "Which of these best describes person 2’s gender identity?"
@type = "radio"
@check_answers_card_number = 2
@hint_text = ""
@answer_options = ANSWER_OPTIONS
end
ANSWER_OPTIONS = { "F" => { "value" => "Female" }, "M" => { "value" => "Male" }, "X" => { "value" => "Non-binary" }, "divider" => { "value" => true }, "R" => { "value" => "Person prefers not to say" } }.freeze
end

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

@ -1,14 +0,0 @@
class Form::Lettings::Questions::Sex3 < ::Form::Question
def initialize(id, hsh, page)
super
@id = "sex3"
@check_answer_label = "Person 3’s gender identity"
@header = "Which of these best describes person 3’s gender identity?"
@type = "radio"
@check_answers_card_number = 3
@hint_text = ""
@answer_options = ANSWER_OPTIONS
end
ANSWER_OPTIONS = { "F" => { "value" => "Female" }, "M" => { "value" => "Male" }, "X" => { "value" => "Non-binary" }, "divider" => { "value" => true }, "R" => { "value" => "Person prefers not to say" } }.freeze
end

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

@ -1,14 +0,0 @@
class Form::Lettings::Questions::Sex4 < ::Form::Question
def initialize(id, hsh, page)
super
@id = "sex4"
@check_answer_label = "Person 4’s gender identity"
@header = "Which of these best describes person 4’s gender identity?"
@type = "radio"
@check_answers_card_number = 4
@hint_text = ""
@answer_options = ANSWER_OPTIONS
end
ANSWER_OPTIONS = { "F" => { "value" => "Female" }, "M" => { "value" => "Male" }, "X" => { "value" => "Non-binary" }, "divider" => { "value" => true }, "R" => { "value" => "Person prefers not to say" } }.freeze
end

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

@ -1,14 +0,0 @@
class Form::Lettings::Questions::Sex5 < ::Form::Question
def initialize(id, hsh, page)
super
@id = "sex5"
@check_answer_label = "Person 5’s gender identity"
@header = "Which of these best describes person 5’s gender identity?"
@type = "radio"
@check_answers_card_number = 5
@hint_text = ""
@answer_options = ANSWER_OPTIONS
end
ANSWER_OPTIONS = { "F" => { "value" => "Female" }, "M" => { "value" => "Male" }, "X" => { "value" => "Non-binary" }, "divider" => { "value" => true }, "R" => { "value" => "Person prefers not to say" } }.freeze
end

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

@ -1,14 +0,0 @@
class Form::Lettings::Questions::Sex6 < ::Form::Question
def initialize(id, hsh, page)
super
@id = "sex6"
@check_answer_label = "Person 6’s gender identity"
@header = "Which of these best describes person 6’s gender identity?"
@type = "radio"
@check_answers_card_number = 6
@hint_text = ""
@answer_options = ANSWER_OPTIONS
end
ANSWER_OPTIONS = { "F" => { "value" => "Female" }, "M" => { "value" => "Male" }, "X" => { "value" => "Non-binary" }, "divider" => { "value" => true }, "R" => { "value" => "Person prefers not to say" } }.freeze
end

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

@ -1,14 +0,0 @@
class Form::Lettings::Questions::Sex7 < ::Form::Question
def initialize(id, hsh, page)
super
@id = "sex7"
@check_answer_label = "Person 7’s gender identity"
@header = "Which of these best describes person 7’s gender identity?"
@type = "radio"
@check_answers_card_number = 7
@hint_text = ""
@answer_options = ANSWER_OPTIONS
end
ANSWER_OPTIONS = { "F" => { "value" => "Female" }, "M" => { "value" => "Male" }, "X" => { "value" => "Non-binary" }, "divider" => { "value" => true }, "R" => { "value" => "Person prefers not to say" } }.freeze
end

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

@ -1,14 +0,0 @@
class Form::Lettings::Questions::Sex8 < ::Form::Question
def initialize(id, hsh, page)
super
@id = "sex8"
@check_answer_label = "Person 8’s gender identity"
@header = "Which of these best describes person 8’s gender identity?"
@type = "radio"
@check_answers_card_number = 8
@hint_text = ""
@answer_options = ANSWER_OPTIONS
end
ANSWER_OPTIONS = { "F" => { "value" => "Female" }, "M" => { "value" => "Male" }, "X" => { "value" => "Non-binary" }, "divider" => { "value" => true }, "R" => { "value" => "Person prefers not to say" } }.freeze
end

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

@ -32,7 +32,7 @@ class Form::Lettings::Subsections::HouseholdCharacteristics < ::Form::Subsection
Form::Lettings::Pages::PersonAge.new(nil, nil, self, person_index: 2),
Form::Lettings::Pages::NoFemalesPregnantHouseholdPerson2AgeValueCheck.new(nil, nil, self),
Form::Lettings::Pages::FemalesInSoftAgeRangeInPregnantHouseholdPerson2AgeValueCheck.new(nil, nil, self),
Form::Lettings::Pages::Person2GenderIdentity.new(nil, nil, self),
Form::Lettings::Pages::PersonGenderIdentity.new(nil, nil, self, person_index: 2),
Form::Lettings::Pages::NoFemalesPregnantHouseholdPerson2ValueCheck.new(nil, nil, self),
Form::Lettings::Pages::FemalesInSoftAgeRangeInPregnantHouseholdPerson2ValueCheck.new(nil, nil, self),
Form::Lettings::Pages::Person2WorkingSituation.new(nil, nil, self),
@ -43,7 +43,7 @@ class Form::Lettings::Subsections::HouseholdCharacteristics < ::Form::Subsection
Form::Lettings::Pages::PersonAge.new(nil, nil, self, person_index: 3),
Form::Lettings::Pages::NoFemalesPregnantHouseholdPerson3AgeValueCheck.new(nil, nil, self),
Form::Lettings::Pages::FemalesInSoftAgeRangeInPregnantHouseholdPerson3AgeValueCheck.new(nil, nil, self),
Form::Lettings::Pages::Person3GenderIdentity.new(nil, nil, self),
Form::Lettings::Pages::PersonGenderIdentity.new(nil, nil, self, person_index: 3),
Form::Lettings::Pages::NoFemalesPregnantHouseholdPerson3ValueCheck.new(nil, nil, self),
Form::Lettings::Pages::FemalesInSoftAgeRangeInPregnantHouseholdPerson3ValueCheck.new(nil, nil, self),
Form::Lettings::Pages::Person3WorkingSituation.new(nil, nil, self),
@ -54,7 +54,7 @@ class Form::Lettings::Subsections::HouseholdCharacteristics < ::Form::Subsection
Form::Lettings::Pages::PersonAge.new(nil, nil, self, person_index: 4),
Form::Lettings::Pages::NoFemalesPregnantHouseholdPerson4AgeValueCheck.new(nil, nil, self),
Form::Lettings::Pages::FemalesInSoftAgeRangeInPregnantHouseholdPerson4AgeValueCheck.new(nil, nil, self),
Form::Lettings::Pages::Person4GenderIdentity.new(nil, nil, self),
Form::Lettings::Pages::PersonGenderIdentity.new(nil, nil, self, person_index: 4),
Form::Lettings::Pages::NoFemalesPregnantHouseholdPerson4ValueCheck.new(nil, nil, self),
Form::Lettings::Pages::FemalesInSoftAgeRangeInPregnantHouseholdPerson4ValueCheck.new(nil, nil, self),
Form::Lettings::Pages::Person4WorkingSituation.new(nil, nil, self),
@ -65,7 +65,7 @@ class Form::Lettings::Subsections::HouseholdCharacteristics < ::Form::Subsection
Form::Lettings::Pages::PersonAge.new(nil, nil, self, person_index: 5),
Form::Lettings::Pages::NoFemalesPregnantHouseholdPerson5AgeValueCheck.new(nil, nil, self),
Form::Lettings::Pages::FemalesInSoftAgeRangeInPregnantHouseholdPerson5AgeValueCheck.new(nil, nil, self),
Form::Lettings::Pages::Person5GenderIdentity.new(nil, nil, self),
Form::Lettings::Pages::PersonGenderIdentity.new(nil, nil, self, person_index: 5),
Form::Lettings::Pages::NoFemalesPregnantHouseholdPerson5ValueCheck.new(nil, nil, self),
Form::Lettings::Pages::FemalesInSoftAgeRangeInPregnantHouseholdPerson5ValueCheck.new(nil, nil, self),
Form::Lettings::Pages::Person5WorkingSituation.new(nil, nil, self),
@ -76,7 +76,7 @@ class Form::Lettings::Subsections::HouseholdCharacteristics < ::Form::Subsection
Form::Lettings::Pages::PersonAge.new(nil, nil, self, person_index: 6),
Form::Lettings::Pages::NoFemalesPregnantHouseholdPerson6AgeValueCheck.new(nil, nil, self),
Form::Lettings::Pages::FemalesInSoftAgeRangeInPregnantHouseholdPerson6AgeValueCheck.new(nil, nil, self),
Form::Lettings::Pages::Person6GenderIdentity.new(nil, nil, self),
Form::Lettings::Pages::PersonGenderIdentity.new(nil, nil, self, person_index: 6),
Form::Lettings::Pages::NoFemalesPregnantHouseholdPerson6ValueCheck.new(nil, nil, self),
Form::Lettings::Pages::FemalesInSoftAgeRangeInPregnantHouseholdPerson6ValueCheck.new(nil, nil, self),
Form::Lettings::Pages::Person6WorkingSituation.new(nil, nil, self),
@ -87,7 +87,7 @@ class Form::Lettings::Subsections::HouseholdCharacteristics < ::Form::Subsection
Form::Lettings::Pages::PersonAge.new(nil, nil, self, person_index: 7),
Form::Lettings::Pages::NoFemalesPregnantHouseholdPerson7AgeValueCheck.new(nil, nil, self),
Form::Lettings::Pages::FemalesInSoftAgeRangeInPregnantHouseholdPerson7AgeValueCheck.new(nil, nil, self),
Form::Lettings::Pages::Person7GenderIdentity.new(nil, nil, self),
Form::Lettings::Pages::PersonGenderIdentity.new(nil, nil, self, person_index: 7),
Form::Lettings::Pages::NoFemalesPregnantHouseholdPerson7ValueCheck.new(nil, nil, self),
Form::Lettings::Pages::FemalesInSoftAgeRangeInPregnantHouseholdPerson7ValueCheck.new(nil, nil, self),
Form::Lettings::Pages::Person7WorkingSituation.new(nil, nil, self),
@ -98,7 +98,7 @@ class Form::Lettings::Subsections::HouseholdCharacteristics < ::Form::Subsection
Form::Lettings::Pages::PersonAge.new(nil, nil, self, person_index: 8),
Form::Lettings::Pages::NoFemalesPregnantHouseholdPerson8AgeValueCheck.new(nil, nil, self),
Form::Lettings::Pages::FemalesInSoftAgeRangeInPregnantHouseholdPerson8AgeValueCheck.new(nil, nil, self),
Form::Lettings::Pages::Person8GenderIdentity.new(nil, nil, self),
Form::Lettings::Pages::PersonGenderIdentity.new(nil, nil, self, person_index: 8),
Form::Lettings::Pages::NoFemalesPregnantHouseholdPerson8ValueCheck.new(nil, nil, self),
Form::Lettings::Pages::FemalesInSoftAgeRangeInPregnantHouseholdPerson8ValueCheck.new(nil, nil, self),
Form::Lettings::Pages::Person8WorkingSituation.new(nil, nil, self),

55
spec/models/form/lettings/pages/person_gender_identity_spec.rb

@ -0,0 +1,55 @@
require "rails_helper"
RSpec.describe Form::Lettings::Pages::PersonGenderIdentity, 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[sex2])
end
it "has the correct id" do
expect(page.id).to eq("person_2_gender_identity")
end
it "has correct depends_on" do
expect(page.depends_on).to eq(
[{ "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[sex3])
end
it "has the correct id" do
expect(page.id).to eq("person_3_gender_identity")
end
it "has correct depends_on" do
expect(page.depends_on).to eq(
[{ "details_known_3" => 0 }],
)
end
end
end

63
spec/models/form/lettings/questions/person_gender_identity_spec.rb

@ -0,0 +1,63 @@
require "rails_helper"
RSpec.describe Form::Lettings::Questions::PersonGenderIdentity, 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 hint" do
expect(question.hint_text).to eq("")
end
context "with person 2" do
it "has the correct id" do
expect(question.id).to eq("sex2")
end
it "has the correct check_answer_label" do
expect(question.check_answer_label).to eq("Person 2’s gender identity")
end
it "has the correct header" do
expect(question.header).to eq("Which of these best describes person 2’s gender identity?")
end
it "has the correct check_answers_card_number" do
expect(question.check_answers_card_number).to eq(2)
end
end
context "with person 3" do
let(:person_index) { 3 }
it "has the correct id" do
expect(question.id).to eq("sex3")
end
it "has the correct check_answer_label" do
expect(question.check_answer_label).to eq("Person 3’s gender identity")
end
it "has the correct header" do
expect(question.header).to eq("Which of these best describes person 3’s gender identity?")
end
it "has the correct check_answers_card_number" do
expect(question.check_answers_card_number).to eq(3)
end
end
end
Loading…
Cancel
Save