From 04d0a54353393bfbf0a6089dd8fa73d3e3a0ed0b Mon Sep 17 00:00:00 2001 From: Katherine Langford Date: Thu, 15 Jan 2026 16:58:40 +0000 Subject: [PATCH] CLCD-4177: Unit tests --- .../person_sex_registered_at_birth.rb | 2 +- .../questions/sex_registered_at_birth2.rb | 4 +- .../subsections/household_characteristics.rb | 14 +- .../person_sex_registered_at_birth_spec.rb | 104 ++++++++++++++ .../pages/sex_registered_at_birth1_spec.rb | 29 ++++ .../pages/sex_registered_at_birth2_spec.rb | 38 +++++ .../person_sex_registered_at_birth_spec.rb | 133 ++++++++++++++++++ .../sex_registered_at_birth1_spec.rb | 45 ++++++ .../sex_registered_at_birth2_spec.rb | 51 +++++++ .../household_characteristics_spec.rb | 131 +++++++++++++++++ 10 files changed, 541 insertions(+), 10 deletions(-) create mode 100644 spec/models/form/sales/pages/person_sex_registered_at_birth_spec.rb create mode 100644 spec/models/form/sales/pages/sex_registered_at_birth1_spec.rb create mode 100644 spec/models/form/sales/pages/sex_registered_at_birth2_spec.rb create mode 100644 spec/models/form/sales/questions/person_sex_registered_at_birth_spec.rb create mode 100644 spec/models/form/sales/questions/sex_registered_at_birth1_spec.rb create mode 100644 spec/models/form/sales/questions/sex_registered_at_birth2_spec.rb diff --git a/app/models/form/sales/questions/person_sex_registered_at_birth.rb b/app/models/form/sales/questions/person_sex_registered_at_birth.rb index fe1f14fa0..12079761d 100644 --- a/app/models/form/sales/questions/person_sex_registered_at_birth.rb +++ b/app/models/form/sales/questions/person_sex_registered_at_birth.rb @@ -10,7 +10,7 @@ class Form::Sales::Questions::PersonSexRegisteredAtBirth < ::Form::Question "condition" => { id => "R", }, - "value" => "Prefers not to say", + "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] diff --git a/app/models/form/sales/questions/sex_registered_at_birth2.rb b/app/models/form/sales/questions/sex_registered_at_birth2.rb index 073be25a2..23af640c8 100644 --- a/app/models/form/sales/questions/sex_registered_at_birth2.rb +++ b/app/models/form/sales/questions/sex_registered_at_birth2.rb @@ -9,9 +9,9 @@ class Form::Sales::Questions::SexRegisteredAtBirth2 < ::Form::Question @check_answers_card_number = 2 @inferred_check_answers_value = [{ "condition" => { - "sex2" => "R", + "sexRAB2" => "R", }, - "value" => "Prefers not to say", + "value" => "Buyer 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] diff --git a/app/models/form/sales/subsections/household_characteristics.rb b/app/models/form/sales/subsections/household_characteristics.rb index 4542ad49d..47466a492 100644 --- a/app/models/form/sales/subsections/household_characteristics.rb +++ b/app/models/form/sales/subsections/household_characteristics.rb @@ -24,7 +24,7 @@ class Form::Sales::Subsections::HouseholdCharacteristics < ::Form::Subsection (Form::Sales::Pages::NotRetiredValueCheck.new("age_1_not_retired_value_check", nil, self, person_index: 1) if form.start_year_2024_or_later?), Form::Sales::Pages::OldPersonsSharedOwnershipValueCheck.new("age_1_old_persons_shared_ownership_joint_purchase_value_check", nil, self, joint_purchase: true), Form::Sales::Pages::OldPersonsSharedOwnershipValueCheck.new("age_1_old_persons_shared_ownership_value_check", nil, self, joint_purchase: false), - Form::Sales::Pages::SexRegisteredAtBirth1.new(nil, nil, self), + (Form::Sales::Pages::SexRegisteredAtBirth1.new(nil, nil, self) if form.start_year_2026_or_later?), Form::Sales::Pages::GenderIdentity1.new(nil, nil, self), Form::Sales::Pages::Buyer1EthnicGroup.new(nil, nil, self), Form::Sales::Pages::Buyer1EthnicBackgroundBlack.new(nil, nil, self), @@ -47,7 +47,7 @@ class Form::Sales::Subsections::HouseholdCharacteristics < ::Form::Subsection Form::Sales::Pages::RetirementValueCheck.new("age_2_buyer_retirement_value_check", nil, self, person_index: 2), (Form::Sales::Pages::NotRetiredValueCheck.new("age_2_buyer_not_retired_value_check", nil, self, person_index: 2) if form.start_year_2024_or_later?), (Form::Sales::Pages::PersonStudentNotChildValueCheck.new("buyer_2_age_student_not_child_value_check", nil, self, person_index: 2) unless form.start_year_2025_or_later?), - Form::Sales::Pages::SexRegisteredAtBirth2.new(nil, nil, self), + (Form::Sales::Pages::SexRegisteredAtBirth2.new(nil, nil, self) if form.start_year_2026_or_later?), Form::Sales::Pages::GenderIdentity2.new(nil, nil, self), buyer_2_ethnicity_nationality_pages, Form::Sales::Pages::Buyer2WorkingSituation.new(nil, nil, self), @@ -69,7 +69,7 @@ class Form::Sales::Subsections::HouseholdCharacteristics < ::Form::Subsection (Form::Sales::Pages::NotRetiredValueCheck.new("age_2_not_retired_value_check", nil, self, person_index: 2) if form.start_year_2024_or_later?), (Form::Sales::Pages::PersonStudentNotChildValueCheck.new("age_2_student_not_child_value_check", nil, self, person_index: 2) unless form.start_year_2025_or_later?), (Form::Sales::Pages::PartnerUnder16ValueCheck.new("age_2_partner_under_16_value_check", nil, self, person_index: 2) if form.start_year_2024_or_later?), - Form::Sales::Pages::PersonSexRegisteredAtBirth.new("person_2_sex_registered_at_birth", nil, self, person_index: 2), + (Form::Sales::Pages::PersonSexRegisteredAtBirth.new("person_2_sex_registered_at_birth", nil, self, person_index: 2) if form.start_year_2026_or_later?), Form::Sales::Pages::PersonGenderIdentity.new("person_2_gender_identity", nil, self, person_index: 2), Form::Sales::Pages::PersonWorkingSituation.new("person_2_working_situation", nil, self, person_index: 2), Form::Sales::Pages::RetirementValueCheck.new("working_situation_2_retirement_value_check", nil, self, person_index: 2), @@ -85,7 +85,7 @@ class Form::Sales::Subsections::HouseholdCharacteristics < ::Form::Subsection (Form::Sales::Pages::NotRetiredValueCheck.new("age_3_not_retired_value_check", nil, self, person_index: 3) if form.start_year_2024_or_later?), (Form::Sales::Pages::PersonStudentNotChildValueCheck.new("age_3_student_not_child_value_check", nil, self, person_index: 3) unless form.start_year_2025_or_later?), (Form::Sales::Pages::PartnerUnder16ValueCheck.new("age_3_partner_under_16_value_check", nil, self, person_index: 3) if form.start_year_2024_or_later?), - Form::Sales::Pages::PersonSexRegisteredAtBirth.new("person_3_sex_registered_at_birth", nil, self, person_index: 3), + (Form::Sales::Pages::PersonSexRegisteredAtBirth.new("person_3_sex_registered_at_birth", nil, self, person_index: 3) if form.start_year_2026_or_later?), Form::Sales::Pages::PersonGenderIdentity.new("person_3_gender_identity", nil, self, person_index: 3), Form::Sales::Pages::PersonWorkingSituation.new("person_3_working_situation", nil, self, person_index: 3), Form::Sales::Pages::RetirementValueCheck.new("working_situation_3_retirement_value_check", nil, self, person_index: 3), @@ -101,7 +101,7 @@ class Form::Sales::Subsections::HouseholdCharacteristics < ::Form::Subsection (Form::Sales::Pages::NotRetiredValueCheck.new("age_4_not_retired_value_check", nil, self, person_index: 4) if form.start_year_2024_or_later?), (Form::Sales::Pages::PersonStudentNotChildValueCheck.new("age_4_student_not_child_value_check", nil, self, person_index: 4) unless form.start_year_2025_or_later?), (Form::Sales::Pages::PartnerUnder16ValueCheck.new("age_4_partner_under_16_value_check", nil, self, person_index: 4) if form.start_year_2024_or_later?), - Form::Sales::Pages::PersonSexRegisteredAtBirth.new("person_4_sex_registered_at_birth", nil, self, person_index: 4), + (Form::Sales::Pages::PersonSexRegisteredAtBirth.new("person_4_sex_registered_at_birth", nil, self, person_index: 4) if form.start_year_2026_or_later?), Form::Sales::Pages::PersonGenderIdentity.new("person_4_gender_identity", nil, self, person_index: 4), Form::Sales::Pages::PersonWorkingSituation.new("person_4_working_situation", nil, self, person_index: 4), Form::Sales::Pages::RetirementValueCheck.new("working_situation_4_retirement_value_check", nil, self, person_index: 4), @@ -117,7 +117,7 @@ class Form::Sales::Subsections::HouseholdCharacteristics < ::Form::Subsection (Form::Sales::Pages::NotRetiredValueCheck.new("age_5_not_retired_value_check", nil, self, person_index: 5) if form.start_year_2024_or_later?), (Form::Sales::Pages::PersonStudentNotChildValueCheck.new("age_5_student_not_child_value_check", nil, self, person_index: 5) unless form.start_year_2025_or_later?), (Form::Sales::Pages::PartnerUnder16ValueCheck.new("age_5_partner_under_16_value_check", nil, self, person_index: 5) if form.start_year_2024_or_later?), - Form::Sales::Pages::PersonSexRegisteredAtBirth.new("person_5_sex_registered_at_birth", nil, self, person_index: 5), + (Form::Sales::Pages::PersonSexRegisteredAtBirth.new("person_5_sex_registered_at_birth", nil, self, person_index: 5) if form.start_year_2026_or_later?), Form::Sales::Pages::PersonGenderIdentity.new("person_5_gender_identity", nil, self, person_index: 5), Form::Sales::Pages::PersonWorkingSituation.new("person_5_working_situation", nil, self, person_index: 5), Form::Sales::Pages::RetirementValueCheck.new("working_situation_5_retirement_value_check", nil, self, person_index: 5), @@ -133,7 +133,7 @@ class Form::Sales::Subsections::HouseholdCharacteristics < ::Form::Subsection (Form::Sales::Pages::NotRetiredValueCheck.new("age_6_not_retired_value_check", nil, self, person_index: 6) if form.start_year_2024_or_later?), (Form::Sales::Pages::PersonStudentNotChildValueCheck.new("age_6_student_not_child_value_check", nil, self, person_index: 6) unless form.start_year_2025_or_later?), (Form::Sales::Pages::PartnerUnder16ValueCheck.new("age_6_partner_under_16_value_check", nil, self, person_index: 6) if form.start_year_2024_or_later?), - Form::Sales::Pages::PersonSexRegisteredAtBirth.new("person_6_sex_registered_at_birth", nil, self, person_index: 6), + (Form::Sales::Pages::PersonSexRegisteredAtBirth.new("person_6_sex_registered_at_birth", nil, self, person_index: 6) if form.start_year_2026_or_later?), Form::Sales::Pages::PersonGenderIdentity.new("person_6_gender_identity", nil, self, person_index: 6), Form::Sales::Pages::PersonWorkingSituation.new("person_6_working_situation", nil, self, person_index: 6), Form::Sales::Pages::RetirementValueCheck.new("working_situation_6_retirement_value_check", nil, self, person_index: 6), diff --git a/spec/models/form/sales/pages/person_sex_registered_at_birth_spec.rb b/spec/models/form/sales/pages/person_sex_registered_at_birth_spec.rb new file mode 100644 index 000000000..0885e1d3e --- /dev/null +++ b/spec/models/form/sales/pages/person_sex_registered_at_birth_spec.rb @@ -0,0 +1,104 @@ +require "rails_helper" + +RSpec.describe Form::Sales::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 +end diff --git a/spec/models/form/sales/pages/sex_registered_at_birth1_spec.rb b/spec/models/form/sales/pages/sex_registered_at_birth1_spec.rb new file mode 100644 index 000000000..2339a1064 --- /dev/null +++ b/spec/models/form/sales/pages/sex_registered_at_birth1_spec.rb @@ -0,0 +1,29 @@ +require "rails_helper" + +RSpec.describe Form::Sales::Pages::SexRegisteredAtBirth1, 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("buyer_1_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([{ "buyer_has_seen_privacy_notice?" => true }, { "buyer_not_interviewed?" => true }]) + end +end diff --git a/spec/models/form/sales/pages/sex_registered_at_birth2_spec.rb b/spec/models/form/sales/pages/sex_registered_at_birth2_spec.rb new file mode 100644 index 000000000..cb1a20cdd --- /dev/null +++ b/spec/models/form/sales/pages/sex_registered_at_birth2_spec.rb @@ -0,0 +1,38 @@ +require "rails_helper" + +RSpec.describe Form::Sales::Pages::SexRegisteredAtBirth2, 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[sexRAB2]) + end + + it "has the correct id" do + expect(page.id).to eq("buyer_2_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([ + { + "joint_purchase?" => true, + "buyer_has_seen_privacy_notice?" => true, + }, + { + "joint_purchase?" => true, + "buyer_not_interviewed?" => true, + }, + ]) + end +end diff --git a/spec/models/form/sales/questions/person_sex_registered_at_birth_spec.rb b/spec/models/form/sales/questions/person_sex_registered_at_birth_spec.rb new file mode 100644 index 000000000..804a390c2 --- /dev/null +++ b/spec/models/form/sales/questions/person_sex_registered_at_birth_spec.rb @@ -0,0 +1,133 @@ +require "rails_helper" + +RSpec.describe Form::Sales::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 +end diff --git a/spec/models/form/sales/questions/sex_registered_at_birth1_spec.rb b/spec/models/form/sales/questions/sex_registered_at_birth1_spec.rb new file mode 100644 index 000000000..b6e0a216f --- /dev/null +++ b/spec/models/form/sales/questions/sex_registered_at_birth1_spec.rb @@ -0,0 +1,45 @@ +require "rails_helper" + +RSpec.describe Form::Sales::Questions::SexRegisteredAtBirth1, 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" => "Buyer 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/sales/questions/sex_registered_at_birth2_spec.rb b/spec/models/form/sales/questions/sex_registered_at_birth2_spec.rb new file mode 100644 index 000000000..bad96fc20 --- /dev/null +++ b/spec/models/form/sales/questions/sex_registered_at_birth2_spec.rb @@ -0,0 +1,51 @@ +require "rails_helper" + +RSpec.describe Form::Sales::Questions::SexRegisteredAtBirth2, 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("sexRAB2") + 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" => "Buyer prefers not to say" }, + }) + end + + it "has the correct 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" => "Buyer prefers not to say" }, + ]) + end +end diff --git a/spec/models/form/sales/subsections/household_characteristics_spec.rb b/spec/models/form/sales/subsections/household_characteristics_spec.rb index 67f758ae3..392391381 100644 --- a/spec/models/form/sales/subsections/household_characteristics_spec.rb +++ b/spec/models/form/sales/subsections/household_characteristics_spec.rb @@ -21,6 +21,7 @@ RSpec.describe Form::Sales::Subsections::HouseholdCharacteristics, type: :model allow(form).to receive(:start_date).and_return(Time.zone.local(2023, 4, 1)) allow(form).to receive(:start_year_2024_or_later?).and_return(false) allow(form).to receive(:start_year_2025_or_later?).and_return(false) + allow(form).to receive(:start_year_2026_or_later?).and_return(false) end it "has correct pages" do @@ -130,6 +131,7 @@ RSpec.describe Form::Sales::Subsections::HouseholdCharacteristics, type: :model allow(form).to receive(:start_date).and_return(Time.zone.local(2024, 4, 1)) allow(form).to receive(:start_year_2024_or_later?).and_return(true) allow(form).to receive(:start_year_2025_or_later?).and_return(false) + allow(form).to receive(:start_year_2026_or_later?).and_return(false) end it "has correct depends on" do @@ -284,6 +286,7 @@ RSpec.describe Form::Sales::Subsections::HouseholdCharacteristics, type: :model allow(form).to receive(:start_date).and_return(Time.zone.local(2025, 4, 1)) allow(form).to receive(:start_year_2024_or_later?).and_return(true) allow(form).to receive(:start_year_2025_or_later?).and_return(true) + allow(form).to receive(:start_year_2026_or_later?).and_return(false) end it "has correct pages" do @@ -398,4 +401,132 @@ RSpec.describe Form::Sales::Subsections::HouseholdCharacteristics, type: :model expect(household_characteristics.depends_on).to eq([{ "setup_completed?" => true }]) end end + + context "with 2026/27 form" do + before do + allow(form).to receive(:start_date).and_return(Time.zone.local(2026, 4, 1)) + allow(form).to receive(:start_year_2024_or_later?).and_return(true) + allow(form).to receive(:start_year_2025_or_later?).and_return(true) + allow(form).to receive(:start_year_2026_or_later?).and_return(true) + end + + it "has correct pages" do + expect(household_characteristics.pages.map(&:id)).to eq( + %w[ + buyer_1_age + age_1_retirement_value_check + age_1_not_retired_value_check + age_1_old_persons_shared_ownership_joint_purchase_value_check + age_1_old_persons_shared_ownership_value_check + buyer_1_sex_registered_at_birth + buyer_1_gender_identity + buyer_1_ethnic_group + buyer_1_ethnic_background_black + buyer_1_ethnic_background_asian + buyer_1_ethnic_background_arab + buyer_1_ethnic_background_mixed + buyer_1_ethnic_background_white + buyer_1_nationality + buyer_1_working_situation + working_situation_1_retirement_value_check + working_situation_1_not_retired_value_check + working_situation_buyer_1_income_value_check + buyer_1_live_in_property + buyer_1_live_in_property_value_check + buyer_2_relationship_to_buyer_1 + buyer_2_age + age_2_old_persons_shared_ownership_joint_purchase_value_check + age_2_old_persons_shared_ownership_value_check + age_2_buyer_retirement_value_check + age_2_buyer_not_retired_value_check + buyer_2_sex_registered_at_birth + buyer_2_gender_identity + buyer_2_ethnic_group + buyer_2_ethnic_background_black + buyer_2_ethnic_background_asian + buyer_2_ethnic_background_arab + buyer_2_ethnic_background_mixed + buyer_2_ethnic_background_white + buyer_2_nationality + buyer_2_working_situation + working_situation_2_retirement_value_check_joint_purchase + working_situation_2_not_retired_value_check_joint_purchase + working_situation_buyer_2_income_value_check + buyer_2_live_in_property + buyer_2_live_in_property_value_check + number_of_others_in_property + number_of_others_in_property_joint_purchase + person_2_known + person_2_relationship_to_buyer_1 + relationship_2_partner_under_16_value_check + relationship_2_multiple_partners_value_check + person_2_age + age_2_retirement_value_check + age_2_not_retired_value_check + age_2_partner_under_16_value_check + person_2_sex_registered_at_birth + person_2_gender_identity + person_2_working_situation + working_situation_2_retirement_value_check + working_situation_2_not_retired_value_check + person_3_known + person_3_relationship_to_buyer_1 + relationship_3_partner_under_16_value_check + relationship_3_multiple_partners_value_check + person_3_age + age_3_retirement_value_check + age_3_not_retired_value_check + age_3_partner_under_16_value_check + person_3_sex_registered_at_birth + person_3_gender_identity + person_3_working_situation + working_situation_3_retirement_value_check + working_situation_3_not_retired_value_check + person_4_known + person_4_relationship_to_buyer_1 + relationship_4_partner_under_16_value_check + relationship_4_multiple_partners_value_check + person_4_age + age_4_retirement_value_check + age_4_not_retired_value_check + age_4_partner_under_16_value_check + person_4_sex_registered_at_birth + person_4_gender_identity + person_4_working_situation + working_situation_4_retirement_value_check + working_situation_4_not_retired_value_check + person_5_known + person_5_relationship_to_buyer_1 + relationship_5_partner_under_16_value_check + relationship_5_multiple_partners_value_check + person_5_age + age_5_retirement_value_check + age_5_not_retired_value_check + age_5_partner_under_16_value_check + person_5_sex_registered_at_birth + person_5_gender_identity + person_5_working_situation + working_situation_5_retirement_value_check + working_situation_5_not_retired_value_check + person_6_known + person_6_relationship_to_buyer_1 + relationship_6_partner_under_16_value_check + relationship_6_multiple_partners_value_check + person_6_age + age_6_retirement_value_check + age_6_not_retired_value_check + age_6_partner_under_16_value_check + person_6_sex_registered_at_birth + person_6_gender_identity + person_6_working_situation + working_situation_6_retirement_value_check + working_situation_6_not_retired_value_check + ], + ) + end + + it "has correct depends on" do + expect(household_characteristics.depends_on).to eq([{ "setup_completed?" => true }]) + end + end end