21 changed files with 155 additions and 198 deletions
@ -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 |
||||
@ -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 |
||||
@ -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 |
||||
@ -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 |
||||
@ -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 |
||||
@ -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 |
||||
@ -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 |
||||
@ -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 |
||||
@ -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" |
||||
@ -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 |
||||
@ -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 |
||||
@ -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 |
||||
@ -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 |
||||
@ -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 |
||||
@ -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 |
||||
@ -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 |
||||
@ -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 |
||||
@ -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 |
||||
@ -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…
Reference in new issue