diff --git a/app/models/form/lettings/pages/lead_tenant_sex_registered_at_birth.rb b/app/models/form/lettings/pages/lead_tenant_sex_registered_at_birth.rb index fed7ec470..46900b9ce 100644 --- a/app/models/form/lettings/pages/lead_tenant_sex_registered_at_birth.rb +++ b/app/models/form/lettings/pages/lead_tenant_sex_registered_at_birth.rb @@ -9,7 +9,7 @@ class Form::Lettings::Pages::LeadTenantSexRegisteredAtBirth < ::Form::Page def questions @questions ||= [ - Form::Lettings::Questions::SexRegisteredAtBirth1.new(nil, nil, self), + Form::Lettings::Questions::LeadTenantSexRegisteredAtBirth.new(nil, nil, self), ] end end diff --git a/app/models/form/lettings/pages/person_sex_registered_at_birth.rb b/app/models/form/lettings/pages/person_sex_registered_at_birth.rb index ea1586f5e..3c5b033ba 100644 --- a/app/models/form/lettings/pages/person_sex_registered_at_birth.rb +++ b/app/models/form/lettings/pages/person_sex_registered_at_birth.rb @@ -6,7 +6,7 @@ class Form::Lettings::Pages::PersonSexRegisteredAtBirth < ::Form::Page @id = "person_#{person_index}_sex_registered_at_birth" @person_index = person_index @depends_on = [ - { "details_known_#{person_index}" => 0 }, + { "details_known_#{person_index}" => 1 }, ] end diff --git a/app/models/form/lettings/questions/sex_registered_at_birth1.rb b/app/models/form/lettings/questions/lead_tenant_sex_registered_at_birth.rb similarity index 87% rename from app/models/form/lettings/questions/sex_registered_at_birth1.rb rename to app/models/form/lettings/questions/lead_tenant_sex_registered_at_birth.rb index 812f8785d..d9eb5d38f 100644 --- a/app/models/form/lettings/questions/sex_registered_at_birth1.rb +++ b/app/models/form/lettings/questions/lead_tenant_sex_registered_at_birth.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -class Form::Lettings::Questions::SexRegisteredAtBirth1 < ::Form::Question +class Form::Lettings::Questions::LeadTenantSexRegisteredAtBirth < ::Form::Question def initialize(id, hsh, page) super @id = "sexrab1" diff --git a/app/models/form/lettings/questions/person_sex_registered_at_birth.rb b/app/models/form/lettings/questions/person_sex_registered_at_birth.rb index 3d8db0312..0ac96f841 100644 --- a/app/models/form/lettings/questions/person_sex_registered_at_birth.rb +++ b/app/models/form/lettings/questions/person_sex_registered_at_birth.rb @@ -5,6 +5,12 @@ class Form::Lettings::Questions::PersonSexRegisteredAtBirth < ::Form::Question super(id, hsh, page) @type = "radio" @check_answers_card_number = person_index + @inferred_check_answers_value = [{ + "condition" => { + id => "R", + }, + "value" => "Person prefers not to say", + }] @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 diff --git a/spec/models/form/lettings/pages/lead_tenant_sex_registered_at_birth_spec.rb b/spec/models/form/lettings/pages/lead_tenant_sex_registered_at_birth_spec.rb new file mode 100644 index 000000000..fcc655849 --- /dev/null +++ b/spec/models/form/lettings/pages/lead_tenant_sex_registered_at_birth_spec.rb @@ -0,0 +1,29 @@ +require "rails_helper" + +RSpec.describe Form::Lettings::Pages::LeadTenantSexRegisteredAtBirth, type: :model do + subject(:page) { described_class.new(page_id, page_definition, subsection) } + + let(:page_id) { nil } + let(:page_definition) { nil } + let(:subsection) { instance_double(Form::Subsection, form: instance_double(Form, start_date: Time.zone.local(2026, 4, 1))) } + + it "has correct subsection" do + expect(page.subsection).to eq(subsection) + end + + it "has correct questions" do + expect(page.questions.map(&:id)).to eq(%w[sexrab1]) + end + + it "has the correct id" do + expect(page.id).to eq("lead_tenant_sex_registered_at_birth") + end + + it "has the correct description" do + expect(page.description).to be_nil + end + + it "has correct depends_on" do + expect(page.depends_on).to eq([{ "declaration" => 1 }]) + end +end diff --git a/spec/models/form/lettings/pages/person_sex_registered_at_birth_spec.rb b/spec/models/form/lettings/pages/person_sex_registered_at_birth_spec.rb new file mode 100644 index 000000000..098911bfc --- /dev/null +++ b/spec/models/form/lettings/pages/person_sex_registered_at_birth_spec.rb @@ -0,0 +1,138 @@ +require "rails_helper" + +RSpec.describe Form::Lettings::Pages::PersonSexRegisteredAtBirth, type: :model do + subject(:page) { described_class.new(page_id, page_definition, subsection, person_index:) } + + let(:page_definition) { nil } + let(:subsection) { instance_double(Form::Subsection, form: instance_double(Form, start_date: Time.zone.local(2026, 4, 1))) } + let(:person_index) { 1 } + + let(:page_id) { "person_2_sex_registered_at_birth" } + + it "has correct subsection" do + expect(page.subsection).to eq(subsection) + end + + it "has the correct description" do + expect(page.description).to be_nil + end + + context "with person 2" do + let(:person_index) { 2 } + let(:page_id) { "person_2_sex_registered_at_birth" } + + it "has correct questions" do + expect(page.questions.map(&:id)).to eq(%w[sexrab2]) + end + + it "has the correct id" do + expect(page.id).to eq("person_2_sex_registered_at_birth") + end + + it "has correct depends_on" do + expect(page.depends_on).to eq([{ "details_known_2" => 1 }]) + end + end + + context "with person 3" do + let(:person_index) { 3 } + let(:page_id) { "person_3_sex_registered_at_birth" } + + it "has correct questions" do + expect(page.questions.map(&:id)).to eq(%w[sexrab3]) + end + + it "has the correct id" do + expect(page.id).to eq("person_3_sex_registered_at_birth") + end + + it "has correct depends_on" do + expect(page.depends_on).to eq([{ "details_known_3" => 1 }]) + end + end + + context "with person 4" do + let(:person_index) { 4 } + let(:page_id) { "person_4_sex_registered_at_birth" } + + it "has correct questions" do + expect(page.questions.map(&:id)).to eq(%w[sexrab4]) + end + + it "has the correct id" do + expect(page.id).to eq("person_4_sex_registered_at_birth") + end + + it "has correct depends_on" do + expect(page.depends_on).to eq([{ "details_known_4" => 1 }]) + end + end + + context "with person 5" do + let(:person_index) { 5 } + let(:page_id) { "person_5_sex_registered_at_birth" } + + it "has correct questions" do + expect(page.questions.map(&:id)).to eq(%w[sexrab5]) + end + + it "has the correct id" do + expect(page.id).to eq("person_5_sex_registered_at_birth") + end + + it "has correct depends_on" do + expect(page.depends_on).to eq([{ "details_known_5" => 1 }]) + end + end + + context "with person 6" do + let(:person_index) { 6 } + let(:page_id) { "person_6_sex_registered_at_birth" } + + it "has correct questions" do + expect(page.questions.map(&:id)).to eq(%w[sexrab6]) + end + + it "has the correct id" do + expect(page.id).to eq("person_6_sex_registered_at_birth") + end + + it "has correct depends_on" do + expect(page.depends_on).to eq([{ "details_known_6" => 1 }]) + end + end + + context "with person 7" do + let(:person_index) { 7 } + let(:page_id) { "person_7_sex_registered_at_birth" } + + it "has correct questions" do + expect(page.questions.map(&:id)).to eq(%w[sexrab7]) + end + + it "has the correct id" do + expect(page.id).to eq("person_7_sex_registered_at_birth") + end + + it "has correct depends_on" do + expect(page.depends_on).to eq([{ "details_known_7" => 1 }]) + end + end + + context "with person 8" do + let(:person_index) { 8 } + let(:page_id) { "person_8_sex_registered_at_birth" } + + it "has correct questions" do + expect(page.questions.map(&:id)).to eq(%w[sexrab8]) + end + + it "has the correct id" do + expect(page.id).to eq("person_8_sex_registered_at_birth") + end + + it "has correct depends_on" do + expect(page.depends_on).to eq([{ "details_known_8" => 1 }]) + end + end +end diff --git a/spec/models/form/lettings/questions/lead_tenant_sex_registered_at_birth_spec.rb b/spec/models/form/lettings/questions/lead_tenant_sex_registered_at_birth_spec.rb new file mode 100644 index 000000000..2707b0246 --- /dev/null +++ b/spec/models/form/lettings/questions/lead_tenant_sex_registered_at_birth_spec.rb @@ -0,0 +1,45 @@ +require "rails_helper" + +RSpec.describe Form::Lettings::Questions::LeadTenantSexRegisteredAtBirth, type: :model do + subject(:question) { described_class.new(question_id, question_definition, page) } + + let(:question_id) { nil } + let(:question_definition) { nil } + let(:page) { instance_double(Form::Page) } + let(:subsection) { instance_double(Form::Subsection) } + let(:form) { instance_double(Form, start_date: Time.zone.local(2026, 4, 1)) } + + before do + allow(page).to receive(:subsection).and_return(subsection) + allow(subsection).to receive(:form).and_return(form) + end + + it "has correct page" do + expect(question.page).to eq(page) + end + + it "has the correct id" do + expect(question.id).to eq("sexrab1") + end + + it "has the correct type" do + expect(question.type).to eq("radio") + end + + it "is not marked as derived" do + expect(question.derived?(nil)).to be false + end + + it "has the correct answer_options" do + expect(question.answer_options).to eq({ + "F" => { "value" => "Female" }, + "M" => { "value" => "Male" }, + "divider" => { "value" => true }, + "R" => { "value" => "Lead tenant prefers not to say" }, + }) + end + + it "has the correct check_answers_card_number" do + expect(question.check_answers_card_number).to eq(1) + end +end diff --git a/spec/models/form/lettings/questions/person_sex_registered_at_birth_spec.rb b/spec/models/form/lettings/questions/person_sex_registered_at_birth_spec.rb new file mode 100644 index 000000000..e80417c5b --- /dev/null +++ b/spec/models/form/lettings/questions/person_sex_registered_at_birth_spec.rb @@ -0,0 +1,171 @@ +require "rails_helper" + +RSpec.describe Form::Lettings::Questions::PersonSexRegisteredAtBirth, type: :model do + subject(:question) { described_class.new(question_id, question_definition, page, person_index:) } + + let(:question_id) { "sexrab2" } + let(:question_definition) { nil } + let(:page) { instance_double(Form::Page) } + let(:person_index) { 2 } + let(:subsection) { instance_double(Form::Subsection) } + let(:form) { instance_double(Form, start_date: Time.zone.local(2026, 4, 1)) } + + before do + allow(page).to receive(:subsection).and_return(subsection) + allow(subsection).to receive(:form).and_return(form) + end + + 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?(nil)).to be false + end + + it "has the correct answer_options" do + expect(question.answer_options).to eq({ + "F" => { "value" => "Female" }, + "M" => { "value" => "Male" }, + "divider" => { "value" => true }, + "R" => { "value" => "Person prefers not to say" }, + }) + end + + context "when person 2" do + let(:question_id) { "sexrab2" } + let(:person_index) { 2 } + + it "has the correct id" do + expect(question.id).to eq("sexrab2") + end + + it "has expected check answers card number" do + expect(question.check_answers_card_number).to eq(2) + end + + it "has the correct inferred_check_answers_value" do + expect(question.inferred_check_answers_value).to eq([ + { "condition" => { "sexrab2" => "R" }, "value" => "Person prefers not to say" }, + ]) + end + end + + context "when person 3" do + let(:question_id) { "sexrab3" } + let(:person_index) { 3 } + + it "has the correct id" do + expect(question.id).to eq("sexrab3") + end + + it "has expected check answers card number" do + expect(question.check_answers_card_number).to eq(3) + end + + it "has the correct inferred_check_answers_value" do + expect(question.inferred_check_answers_value).to eq([ + { "condition" => { "sexrab3" => "R" }, "value" => "Person prefers not to say" }, + ]) + end + end + + context "when person 4" do + let(:question_id) { "sexrab4" } + let(:person_index) { 4 } + + it "has the correct id" do + expect(question.id).to eq("sexrab4") + end + + it "has expected check answers card number" do + expect(question.check_answers_card_number).to eq(4) + end + + it "has the correct inferred_check_answers_value" do + expect(question.inferred_check_answers_value).to eq([ + { "condition" => { "sexrab4" => "R" }, "value" => "Person prefers not to say" }, + ]) + end + end + + context "when person 5" do + let(:question_id) { "sexrab5" } + let(:person_index) { 5 } + + it "has the correct id" do + expect(question.id).to eq("sexrab5") + end + + it "has expected check answers card number" do + expect(question.check_answers_card_number).to eq(5) + end + + it "has the correct inferred_check_answers_value" do + expect(question.inferred_check_answers_value).to eq([ + { "condition" => { "sexrab5" => "R" }, "value" => "Person prefers not to say" }, + ]) + end + end + + context "when person 6" do + let(:question_id) { "sexrab6" } + let(:person_index) { 6 } + + it "has the correct id" do + expect(question.id).to eq("sexrab6") + end + + it "has expected check answers card number" do + expect(question.check_answers_card_number).to eq(6) + end + + it "has the correct inferred_check_answers_value" do + expect(question.inferred_check_answers_value).to eq([ + { "condition" => { "sexrab6" => "R" }, "value" => "Person prefers not to say" }, + ]) + end + end + + context "when person 7" do + let(:question_id) { "sexrab7" } + let(:person_index) { 7 } + + it "has the correct id" do + expect(question.id).to eq("sexrab7") + end + + it "has expected check answers card number" do + expect(question.check_answers_card_number).to eq(7) + end + + it "has the correct inferred_check_answers_value" do + expect(question.inferred_check_answers_value).to eq([ + { "condition" => { "sexrab7" => "R" }, "value" => "Person prefers not to say" }, + ]) + end + end + + context "when person 8" do + let(:question_id) { "sexrab8" } + let(:person_index) { 8 } + + it "has the correct id" do + expect(question.id).to eq("sexrab8") + end + + it "has expected check answers card number" do + expect(question.check_answers_card_number).to eq(8) + end + + it "has the correct inferred_check_answers_value" do + expect(question.inferred_check_answers_value).to eq([ + { "condition" => { "sexrab8" => "R" }, "value" => "Person prefers not to say" }, + ]) + end + end +end