Browse Source

CLDC-3738: Sales - Update household characteristics Q29 and Q38 (25/26) (#2774)

* Create 2025 versions of these questions

* Remove blank line

* Update copy and use 2025 version of question

* Add tests

* Update depends on

* Update question number

* Update test

* Remove depends_on companybuy which has been removed

* Fix lint
pull/2796/head
Manny Dinssa 1 month ago committed by GitHub
parent
commit
4dc323059f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 14
      app/models/form/sales/pages/buyer2_relationship_to_buyer1_yes_no.rb
  2. 15
      app/models/form/sales/pages/person_relationship_to_buyer_1_yes_no.rb
  3. 1
      app/models/form/sales/questions/buyer2_relationship_to_buyer1.rb
  4. 23
      app/models/form/sales/questions/buyer2_relationship_to_buyer1_yes_no.rb
  5. 29
      app/models/form/sales/questions/person_relationship_to_buyer_1_yes_no.rb
  6. 23
      app/models/form/sales/subsections/household_characteristics.rb
  7. 24
      config/locales/forms/2025/sales/household_characteristics.en.yml
  8. 29
      spec/models/form/sales/pages/buyer2_relationship_to_buyer1_yes_no_spec.rb
  9. 87
      spec/models/form/sales/pages/person_relationship_to_buyer1_yes_no_spec.rb
  10. 43
      spec/models/form/sales/questions/buyer2_relationship_to_buyer1_yes_no_spec.rb
  11. 110
      spec/models/form/sales/questions/person_relationship_to_buyer1_yes_no_spec.rb
  12. 181
      spec/models/form/sales/subsections/household_characteristics_spec.rb

14
app/models/form/sales/pages/buyer2_relationship_to_buyer1_yes_no.rb

@ -0,0 +1,14 @@
class Form::Sales::Pages::Buyer2RelationshipToBuyer1YesNo < ::Form::Page
def initialize(id, hsh, subsection)
super
@id = "buyer_2_relationship_to_buyer_1"
@copy_key = "sales.household_characteristics.relat2.buyer"
@depends_on = [{ "joint_purchase?" => true }]
end
def questions
@questions ||= [
Form::Sales::Questions::Buyer2RelationshipToBuyer1YesNo.new(nil, nil, self),
]
end
end

15
app/models/form/sales/pages/person_relationship_to_buyer_1_yes_no.rb

@ -0,0 +1,15 @@
class Form::Sales::Pages::PersonRelationshipToBuyer1YesNo < ::Form::Sales::Pages::Person
def initialize(id, hsh, subsection, person_index:)
super
@copy_key = "sales.household_characteristics.relat2.person" if person_index == 2
@depends_on = [
{ "details_known_#{person_index}" => 1 },
]
end
def questions
@questions ||= [
Form::Sales::Questions::PersonRelationshipToBuyer1YesNo.new("relat#{@person_index}", nil, self, person_index: @person_index),
]
end
end

1
app/models/form/sales/questions/buyer2_relationship_to_buyer1.rb

@ -17,7 +17,6 @@ class Form::Sales::Questions::Buyer2RelationshipToBuyer1 < ::Form::Question
def answer_options def answer_options
if form.start_year_2024_or_later? if form.start_year_2024_or_later?
{ {
"P" => { "value" => "Partner" }, "P" => { "value" => "Partner" },
"C" => { "value" => "Child" }, "C" => { "value" => "Child" },

23
app/models/form/sales/questions/buyer2_relationship_to_buyer1_yes_no.rb

@ -0,0 +1,23 @@
class Form::Sales::Questions::Buyer2RelationshipToBuyer1YesNo < ::Form::Question
def initialize(id, hsh, page)
super
@id = "relat2"
@copy_key = "sales.household_characteristics.relat2.buyer"
@type = "radio"
@answer_options = {
"P" => { "value" => "Yes" },
"X" => { "value" => "No" },
"R" => { "value" => "Buyer prefers not to say" },
}
@inferred_check_answers_value = [{
"condition" => {
"relat2" => "R",
},
"value" => "Prefers not to say",
}]
@check_answers_card_number = 2
@question_number = QUESTION_NUMBER_FROM_YEAR[form.start_date.year] || QUESTION_NUMBER_FROM_YEAR[QUESTION_NUMBER_FROM_YEAR.keys.max]
end
QUESTION_NUMBER_FROM_YEAR = { 2025 => 29 }.freeze
end

29
app/models/form/sales/questions/person_relationship_to_buyer_1_yes_no.rb

@ -0,0 +1,29 @@
class Form::Sales::Questions::PersonRelationshipToBuyer1YesNo < ::Form::Question
def initialize(id, hsh, page, person_index:)
super(id, hsh, page)
@type = "radio"
@copy_key = "sales.household_characteristics.relat2.person" if person_index == 2
@answer_options = {
"P" => { "value" => "Yes" },
"X" => { "value" => "No" },
"R" => { "value" => "Person prefers not to say" },
}
@inferred_check_answers_value = [{
"condition" => {
id => "R",
},
"value" => "Prefers not to say",
}]
@check_answers_card_number = person_index
@person_index = person_index
@question_number = question_number
end
def question_number
base_question_number = QUESTION_NUMBER_FROM_YEAR[form.start_date.year] || QUESTION_NUMBER_FROM_YEAR[QUESTION_NUMBER_FROM_YEAR.keys.max]
base_question_number + (4 * @person_index)
end
QUESTION_NUMBER_FROM_YEAR = { 2025 => 30 }.freeze
end

23
app/models/form/sales/subsections/household_characteristics.rb

@ -3,7 +3,14 @@ class Form::Sales::Subsections::HouseholdCharacteristics < ::Form::Subsection
super super
@id = "household_characteristics" @id = "household_characteristics"
@label = "Household characteristics" @label = "Household characteristics"
@depends_on = [{ "setup_completed?" => true, "company_buyer?" => false }] end
def depends_on
if form.start_year_2025_or_later?
[{ "setup_completed?" => true }]
else
[{ "setup_completed?" => true, "company_buyer?" => false }]
end
end end
def pages def pages
@ -31,7 +38,7 @@ class Form::Sales::Subsections::HouseholdCharacteristics < ::Form::Subsection
Form::Sales::Pages::Buyer1IncomeMinValueCheck.new("working_situation_buyer_1_income_min_value_check", nil, self), Form::Sales::Pages::Buyer1IncomeMinValueCheck.new("working_situation_buyer_1_income_min_value_check", nil, self),
Form::Sales::Pages::Buyer1LiveInProperty.new(nil, nil, self), Form::Sales::Pages::Buyer1LiveInProperty.new(nil, nil, self),
Form::Sales::Pages::BuyerLiveInValueCheck.new("buyer_1_live_in_property_value_check", nil, self, person_index: 1), Form::Sales::Pages::BuyerLiveInValueCheck.new("buyer_1_live_in_property_value_check", nil, self, person_index: 1),
Form::Sales::Pages::Buyer2RelationshipToBuyer1.new(nil, nil, self), (form.start_year_2025_or_later? ? Form::Sales::Pages::Buyer2RelationshipToBuyer1YesNo.new(nil, nil, self) : Form::Sales::Pages::Buyer2RelationshipToBuyer1.new(nil, nil, self)),
Form::Sales::Pages::PersonStudentNotChildValueCheck.new("buyer_2_relationship_student_not_child_value_check", nil, self, person_index: 2), Form::Sales::Pages::PersonStudentNotChildValueCheck.new("buyer_2_relationship_student_not_child_value_check", nil, self, person_index: 2),
Form::Sales::Pages::Age2.new(nil, nil, self), Form::Sales::Pages::Age2.new(nil, nil, self),
Form::Sales::Pages::OldPersonsSharedOwnershipValueCheck.new("age_2_old_persons_shared_ownership_joint_purchase_value_check", nil, self, joint_purchase: true), Form::Sales::Pages::OldPersonsSharedOwnershipValueCheck.new("age_2_old_persons_shared_ownership_joint_purchase_value_check", nil, self, joint_purchase: true),
@ -51,7 +58,7 @@ class Form::Sales::Subsections::HouseholdCharacteristics < ::Form::Subsection
Form::Sales::Pages::NumberOfOthersInProperty.new("number_of_others_in_property", nil, self, joint_purchase: false), Form::Sales::Pages::NumberOfOthersInProperty.new("number_of_others_in_property", nil, self, joint_purchase: false),
Form::Sales::Pages::NumberOfOthersInProperty.new("number_of_others_in_property_joint_purchase", nil, self, joint_purchase: true), Form::Sales::Pages::NumberOfOthersInProperty.new("number_of_others_in_property_joint_purchase", nil, self, joint_purchase: true),
Form::Sales::Pages::PersonKnown.new("person_2_known", nil, self, person_index: 2), Form::Sales::Pages::PersonKnown.new("person_2_known", nil, self, person_index: 2),
Form::Sales::Pages::PersonRelationshipToBuyer1.new("person_2_relationship_to_buyer_1", nil, self, person_index: 2), (form.start_year_2025_or_later? ? Form::Sales::Pages::PersonRelationshipToBuyer1YesNo.new("person_2_relationship_to_buyer_1", nil, self, person_index: 2) : Form::Sales::Pages::PersonRelationshipToBuyer1.new("person_2_relationship_to_buyer_1", nil, self, person_index: 2)),
(Form::Sales::Pages::PartnerUnder16ValueCheck.new("relationship_2_partner_under_16_value_check", nil, self, person_index: 2) if form.start_year_2024_or_later?), (Form::Sales::Pages::PartnerUnder16ValueCheck.new("relationship_2_partner_under_16_value_check", nil, self, person_index: 2) if form.start_year_2024_or_later?),
(Form::Sales::Pages::MultiplePartnersValueCheck.new("relationship_2_multiple_partners_value_check", nil, self, person_index: 2) if form.start_year_2024_or_later?), (Form::Sales::Pages::MultiplePartnersValueCheck.new("relationship_2_multiple_partners_value_check", nil, self, person_index: 2) if form.start_year_2024_or_later?),
Form::Sales::Pages::PersonStudentNotChildValueCheck.new("relationship_2_student_not_child_value_check", nil, self, person_index: 2), Form::Sales::Pages::PersonStudentNotChildValueCheck.new("relationship_2_student_not_child_value_check", nil, self, person_index: 2),
@ -66,7 +73,7 @@ class Form::Sales::Subsections::HouseholdCharacteristics < ::Form::Subsection
(Form::Sales::Pages::NotRetiredValueCheck.new("working_situation_2_not_retired_value_check", nil, self, person_index: 2) if form.start_year_2024_or_later?), (Form::Sales::Pages::NotRetiredValueCheck.new("working_situation_2_not_retired_value_check", nil, self, person_index: 2) if form.start_year_2024_or_later?),
Form::Sales::Pages::PersonStudentNotChildValueCheck.new("working_situation_2_student_not_child_value_check", nil, self, person_index: 2), Form::Sales::Pages::PersonStudentNotChildValueCheck.new("working_situation_2_student_not_child_value_check", nil, self, person_index: 2),
Form::Sales::Pages::PersonKnown.new("person_3_known", nil, self, person_index: 3), Form::Sales::Pages::PersonKnown.new("person_3_known", nil, self, person_index: 3),
Form::Sales::Pages::PersonRelationshipToBuyer1.new("person_3_relationship_to_buyer_1", nil, self, person_index: 3), (form.start_year_2025_or_later? ? Form::Sales::Pages::PersonRelationshipToBuyer1YesNo.new("person_3_relationship_to_buyer_1", nil, self, person_index: 3) : Form::Sales::Pages::PersonRelationshipToBuyer1.new("person_3_relationship_to_buyer_1", nil, self, person_index: 3)),
(Form::Sales::Pages::PartnerUnder16ValueCheck.new("relationship_3_partner_under_16_value_check", nil, self, person_index: 3) if form.start_year_2024_or_later?), (Form::Sales::Pages::PartnerUnder16ValueCheck.new("relationship_3_partner_under_16_value_check", nil, self, person_index: 3) if form.start_year_2024_or_later?),
(Form::Sales::Pages::MultiplePartnersValueCheck.new("relationship_3_multiple_partners_value_check", nil, self, person_index: 3) if form.start_year_2024_or_later?), (Form::Sales::Pages::MultiplePartnersValueCheck.new("relationship_3_multiple_partners_value_check", nil, self, person_index: 3) if form.start_year_2024_or_later?),
Form::Sales::Pages::PersonStudentNotChildValueCheck.new("relationship_3_student_not_child_value_check", nil, self, person_index: 3), Form::Sales::Pages::PersonStudentNotChildValueCheck.new("relationship_3_student_not_child_value_check", nil, self, person_index: 3),
@ -81,7 +88,7 @@ class Form::Sales::Subsections::HouseholdCharacteristics < ::Form::Subsection
(Form::Sales::Pages::NotRetiredValueCheck.new("working_situation_3_not_retired_value_check", nil, self, person_index: 3) if form.start_year_2024_or_later?), (Form::Sales::Pages::NotRetiredValueCheck.new("working_situation_3_not_retired_value_check", nil, self, person_index: 3) if form.start_year_2024_or_later?),
Form::Sales::Pages::PersonStudentNotChildValueCheck.new("working_situation_3_student_not_child_value_check", nil, self, person_index: 3), Form::Sales::Pages::PersonStudentNotChildValueCheck.new("working_situation_3_student_not_child_value_check", nil, self, person_index: 3),
Form::Sales::Pages::PersonKnown.new("person_4_known", nil, self, person_index: 4), Form::Sales::Pages::PersonKnown.new("person_4_known", nil, self, person_index: 4),
Form::Sales::Pages::PersonRelationshipToBuyer1.new("person_4_relationship_to_buyer_1", nil, self, person_index: 4), (form.start_year_2025_or_later? ? Form::Sales::Pages::PersonRelationshipToBuyer1YesNo.new("person_4_relationship_to_buyer_1", nil, self, person_index: 4) : Form::Sales::Pages::PersonRelationshipToBuyer1.new("person_4_relationship_to_buyer_1", nil, self, person_index: 4)),
(Form::Sales::Pages::PartnerUnder16ValueCheck.new("relationship_4_partner_under_16_value_check", nil, self, person_index: 4) if form.start_year_2024_or_later?), (Form::Sales::Pages::PartnerUnder16ValueCheck.new("relationship_4_partner_under_16_value_check", nil, self, person_index: 4) if form.start_year_2024_or_later?),
(Form::Sales::Pages::MultiplePartnersValueCheck.new("relationship_4_multiple_partners_value_check", nil, self, person_index: 4) if form.start_year_2024_or_later?), (Form::Sales::Pages::MultiplePartnersValueCheck.new("relationship_4_multiple_partners_value_check", nil, self, person_index: 4) if form.start_year_2024_or_later?),
Form::Sales::Pages::PersonStudentNotChildValueCheck.new("relationship_4_student_not_child_value_check", nil, self, person_index: 4), Form::Sales::Pages::PersonStudentNotChildValueCheck.new("relationship_4_student_not_child_value_check", nil, self, person_index: 4),
@ -96,7 +103,7 @@ class Form::Sales::Subsections::HouseholdCharacteristics < ::Form::Subsection
(Form::Sales::Pages::NotRetiredValueCheck.new("working_situation_4_not_retired_value_check", nil, self, person_index: 4) if form.start_year_2024_or_later?), (Form::Sales::Pages::NotRetiredValueCheck.new("working_situation_4_not_retired_value_check", nil, self, person_index: 4) if form.start_year_2024_or_later?),
Form::Sales::Pages::PersonStudentNotChildValueCheck.new("working_situation_4_student_not_child_value_check", nil, self, person_index: 4), Form::Sales::Pages::PersonStudentNotChildValueCheck.new("working_situation_4_student_not_child_value_check", nil, self, person_index: 4),
Form::Sales::Pages::PersonKnown.new("person_5_known", nil, self, person_index: 5), Form::Sales::Pages::PersonKnown.new("person_5_known", nil, self, person_index: 5),
Form::Sales::Pages::PersonRelationshipToBuyer1.new("person_5_relationship_to_buyer_1", nil, self, person_index: 5), (form.start_year_2025_or_later? ? Form::Sales::Pages::PersonRelationshipToBuyer1YesNo.new("person_5_relationship_to_buyer_1", nil, self, person_index: 5) : Form::Sales::Pages::PersonRelationshipToBuyer1.new("person_5_relationship_to_buyer_1", nil, self, person_index: 5)),
(Form::Sales::Pages::PartnerUnder16ValueCheck.new("relationship_5_partner_under_16_value_check", nil, self, person_index: 5) if form.start_year_2024_or_later?), (Form::Sales::Pages::PartnerUnder16ValueCheck.new("relationship_5_partner_under_16_value_check", nil, self, person_index: 5) if form.start_year_2024_or_later?),
(Form::Sales::Pages::MultiplePartnersValueCheck.new("relationship_5_multiple_partners_value_check", nil, self, person_index: 5) if form.start_year_2024_or_later?), (Form::Sales::Pages::MultiplePartnersValueCheck.new("relationship_5_multiple_partners_value_check", nil, self, person_index: 5) if form.start_year_2024_or_later?),
Form::Sales::Pages::PersonStudentNotChildValueCheck.new("relationship_5_student_not_child_value_check", nil, self, person_index: 5), Form::Sales::Pages::PersonStudentNotChildValueCheck.new("relationship_5_student_not_child_value_check", nil, self, person_index: 5),
@ -111,7 +118,7 @@ class Form::Sales::Subsections::HouseholdCharacteristics < ::Form::Subsection
(Form::Sales::Pages::NotRetiredValueCheck.new("working_situation_5_not_retired_value_check", nil, self, person_index: 5) if form.start_year_2024_or_later?), (Form::Sales::Pages::NotRetiredValueCheck.new("working_situation_5_not_retired_value_check", nil, self, person_index: 5) if form.start_year_2024_or_later?),
Form::Sales::Pages::PersonStudentNotChildValueCheck.new("working_situation_5_student_not_child_value_check", nil, self, person_index: 5), Form::Sales::Pages::PersonStudentNotChildValueCheck.new("working_situation_5_student_not_child_value_check", nil, self, person_index: 5),
Form::Sales::Pages::PersonKnown.new("person_6_known", nil, self, person_index: 6), Form::Sales::Pages::PersonKnown.new("person_6_known", nil, self, person_index: 6),
Form::Sales::Pages::PersonRelationshipToBuyer1.new("person_6_relationship_to_buyer_1", nil, self, person_index: 6), (form.start_year_2025_or_later? ? Form::Sales::Pages::PersonRelationshipToBuyer1YesNo.new("person_6_relationship_to_buyer_1", nil, self, person_index: 6) : Form::Sales::Pages::PersonRelationshipToBuyer1.new("person_6_relationship_to_buyer_1", nil, self, person_index: 6)),
(Form::Sales::Pages::PartnerUnder16ValueCheck.new("relationship_6_partner_under_16_value_check", nil, self, person_index: 6) if form.start_year_2024_or_later?), (Form::Sales::Pages::PartnerUnder16ValueCheck.new("relationship_6_partner_under_16_value_check", nil, self, person_index: 6) if form.start_year_2024_or_later?),
(Form::Sales::Pages::MultiplePartnersValueCheck.new("relationship_6_multiple_partners_value_check", nil, self, person_index: 6) if form.start_year_2024_or_later?), (Form::Sales::Pages::MultiplePartnersValueCheck.new("relationship_6_multiple_partners_value_check", nil, self, person_index: 6) if form.start_year_2024_or_later?),
Form::Sales::Pages::PersonStudentNotChildValueCheck.new("relationship_6_student_not_child_value_check", nil, self, person_index: 6), Form::Sales::Pages::PersonStudentNotChildValueCheck.new("relationship_6_student_not_child_value_check", nil, self, person_index: 6),
@ -143,6 +150,8 @@ class Form::Sales::Subsections::HouseholdCharacteristics < ::Form::Subsection
end end
def displayed_in_tasklist?(log) def displayed_in_tasklist?(log)
return true if form.start_year_2025_or_later?
!log.company_buyer? !log.company_buyer?
end end
end end

24
config/locales/forms/2025/sales/household_characteristics.en.yml

@ -80,14 +80,14 @@ en:
relat2: relat2:
buyer: buyer:
page_header: "" page_header: ""
check_answer_label: "Buyer 2's relationship to buyer 1" check_answer_label: "Buyer 2 is the partner of buyer 1"
hint_text: "" hint_text: ""
question_text: "What is buyer 2's relationship to buyer 1?" question_text: "Is buyer 2 the partner of buyer 1?"
person: person:
page_header: "" page_header: ""
check_answer_label: "Person 2’s relationship to Buyer 1" check_answer_label: "Person 2 is the partner of buyer 1"
hint_text: "" hint_text: ""
question_text: "What is Person 2’s relationship to Buyer 1?" question_text: "Is person 2 the partner of buyer 1?"
age2: age2:
buyer: buyer:
@ -212,9 +212,9 @@ en:
relat3: relat3:
page_header: "" page_header: ""
check_answer_label: "Person 3’s relationship to Buyer 1" check_answer_label: "Person 3 is the partner of buyer 1"
hint_text: "" hint_text: ""
question_text: "What is Person 3’s relationship to Buyer 1?" question_text: "Is person 3 the partner of buyer 1?"
age3: age3:
page_header: "" page_header: ""
@ -247,9 +247,9 @@ en:
relat4: relat4:
page_header: "" page_header: ""
check_answer_label: "Person 4’s relationship to Buyer 1" check_answer_label: "Person 4 is the partner of buyer 1"
hint_text: "" hint_text: ""
question_text: "What is Person 4’s relationship to Buyer 1?" question_text: "Is person 4 the partner of buyer 1?"
age4: age4:
page_header: "" page_header: ""
@ -282,9 +282,9 @@ en:
relat5: relat5:
page_header: "" page_header: ""
check_answer_label: "Person 5’s relationship to Buyer 1" check_answer_label: "Person 5 is the partner of buyer 1"
hint_text: "" hint_text: ""
question_text: "What is Person 5’s relationship to Buyer 1?" question_text: "Is person 5 the partner of buyer 1?"
age5: age5:
page_header: "" page_header: ""
@ -317,9 +317,9 @@ en:
relat6: relat6:
page_header: "" page_header: ""
check_answer_label: "Person 6’s relationship to Buyer 1" check_answer_label: "Person 6 is the partner of buyer 1"
hint_text: "" hint_text: ""
question_text: "What is Person 6’s relationship to Buyer 1?" question_text: "Is person 6 the partner of buyer 1?"
age6: age6:
page_header: "" page_header: ""

29
spec/models/form/sales/pages/buyer2_relationship_to_buyer1_yes_no_spec.rb

@ -0,0 +1,29 @@
require "rails_helper"
RSpec.describe Form::Sales::Pages::Buyer2RelationshipToBuyer1YesNo, 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(2025, 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[relat2])
end
it "has the correct id" do
expect(page.id).to eq("buyer_2_relationship_to_buyer_1")
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 }])
end
end

87
spec/models/form/sales/pages/person_relationship_to_buyer1_yes_no_spec.rb

@ -0,0 +1,87 @@
require "rails_helper"
RSpec.describe Form::Sales::Pages::PersonRelationshipToBuyer1YesNo, 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(2025, 4, 1))) }
let(:person_index) { 1 }
let(:page_id) { "person_1_relationship_to_buyer_1" }
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_relationship_to_buyer_1" }
it "has correct questions" do
expect(page.questions.map(&:id)).to eq(%w[relat2])
end
it "has the correct id" do
expect(page.id).to eq("person_2_relationship_to_buyer_1")
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_relationship_to_buyer_1" }
it "has correct questions" do
expect(page.questions.map(&:id)).to eq(%w[relat3])
end
it "has the correct id" do
expect(page.id).to eq("person_3_relationship_to_buyer_1")
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_relationship_to_buyer_1" }
it "has correct questions" do
expect(page.questions.map(&:id)).to eq(%w[relat4])
end
it "has the correct id" do
expect(page.id).to eq("person_4_relationship_to_buyer_1")
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_relationship_to_buyer_1" }
it "has correct questions" do
expect(page.questions.map(&:id)).to eq(%w[relat5])
end
it "has the correct id" do
expect(page.id).to eq("person_5_relationship_to_buyer_1")
end
it "has correct depends_on" do
expect(page.depends_on).to eq([{ "details_known_5" => 1 }])
end
end
end

43
spec/models/form/sales/questions/buyer2_relationship_to_buyer1_yes_no_spec.rb

@ -0,0 +1,43 @@
require "rails_helper"
RSpec.describe Form::Sales::Questions::Buyer2RelationshipToBuyer1YesNo, 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, subsection: instance_double(Form::Subsection, form: instance_double(Form, start_date: Time.zone.local(2025, 4, 1)))) }
it "has correct page" do
expect(question.page).to eq(page)
end
it "has the correct id" do
expect(question.id).to eq("relat2")
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({
"P" => { "value" => "Yes" },
"X" => { "value" => "No" },
"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" => { "relat2" => "R" }, "value" => "Prefers not to say" },
])
end
end

110
spec/models/form/sales/questions/person_relationship_to_buyer1_yes_no_spec.rb

@ -0,0 +1,110 @@
require "rails_helper"
RSpec.describe Form::Sales::Questions::PersonRelationshipToBuyer1YesNo, type: :model do
subject(:question) { described_class.new(question_id, question_definition, page, person_index:) }
let(:question_id) { "relat2" }
let(:question_definition) { nil }
let(:page) { instance_double(Form::Page, subsection: instance_double(Form::Subsection, form: instance_double(Form, start_date: Time.zone.local(2025, 4, 1)))) }
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?(nil)).to be false
end
it "has expected check answers card number" do
expect(question.check_answers_card_number).to eq(2)
end
it "has the correct answer_options" do
expect(question.answer_options).to eq({
"P" => { "value" => "Yes" },
"X" => { "value" => "No" },
"R" => { "value" => "Person prefers not to say" },
})
end
context "when person 2" do
let(:question_id) { "relat2" }
let(:person_index) { 2 }
it "has the correct id" do
expect(question.id).to eq("relat2")
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" => { "relat2" => "R" }, "value" => "Prefers not to say" },
])
end
end
context "when person 3" do
let(:question_id) { "relat3" }
let(:person_index) { 3 }
it "has the correct id" do
expect(question.id).to eq("relat3")
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" => { "relat3" => "R" }, "value" => "Prefers not to say" },
])
end
end
context "when person 4" do
let(:question_id) { "relat4" }
let(:person_index) { 4 }
it "has the correct id" do
expect(question.id).to eq("relat4")
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" => { "relat4" => "R" }, "value" => "Prefers not to say" },
])
end
end
context "when person 5" do
let(:question_id) { "relat5" }
let(:person_index) { 5 }
it "has the correct id" do
expect(question.id).to eq("relat5")
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" => { "relat5" => "R" }, "value" => "Prefers not to say" },
])
end
end
end

181
spec/models/form/sales/subsections/household_characteristics_spec.rb

@ -16,10 +16,19 @@ RSpec.describe Form::Sales::Subsections::HouseholdCharacteristics, type: :model
expect(household_characteristics.section).to eq(section) expect(household_characteristics.section).to eq(section)
end end
it "has the correct id" do
expect(household_characteristics.id).to eq("household_characteristics")
end
it "has the correct label" do
expect(household_characteristics.label).to eq("Household characteristics")
end
context "with 2022/23 form" do context "with 2022/23 form" do
before do before do
allow(form).to receive(:start_date).and_return(Time.zone.local(2022, 4, 1)) allow(form).to receive(:start_date).and_return(Time.zone.local(2022, 4, 1))
allow(form).to receive(:start_year_2024_or_later?).and_return(false) allow(form).to receive(:start_year_2024_or_later?).and_return(false)
allow(form).to receive(:start_year_2025_or_later?).and_return(false)
end end
it "has correct pages" do it "has correct pages" do
@ -121,6 +130,7 @@ RSpec.describe Form::Sales::Subsections::HouseholdCharacteristics, type: :model
before do before do
allow(form).to receive(:start_date).and_return(Time.zone.local(2023, 4, 1)) 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_2024_or_later?).and_return(false)
allow(form).to receive(:start_year_2025_or_later?).and_return(false)
end end
it "has correct pages" do it "has correct pages" do
@ -229,6 +239,27 @@ RSpec.describe Form::Sales::Subsections::HouseholdCharacteristics, type: :model
before do before do
allow(form).to receive(:start_date).and_return(Time.zone.local(2024, 4, 1)) 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_2024_or_later?).and_return(true)
allow(form).to receive(:start_year_2025_or_later?).and_return(false)
end
it "has correct depends on" do
expect(household_characteristics.depends_on).to eq([{ "setup_completed?" => true, "company_buyer?" => false }])
end
context "when the sale is to a company buyer" do
let(:log) { FactoryBot.build(:sales_log, ownershipsch: 3, companybuy: 1) }
it "is not displayed in tasklist" do
expect(household_characteristics.displayed_in_tasklist?(log)).to eq(false)
end
end
context "when the sale is not to a company buyer" do
let(:log) { FactoryBot.build(:sales_log, ownershipsch: 3, companybuy: 2) }
it "is displayed in tasklist" do
expect(household_characteristics.displayed_in_tasklist?(log)).to eq(true)
end
end end
it "has correct pages" do it "has correct pages" do
@ -358,31 +389,141 @@ RSpec.describe Form::Sales::Subsections::HouseholdCharacteristics, type: :model
end end
end end
it "has the correct id" do context "with 2025/26 form" do
expect(household_characteristics.id).to eq("household_characteristics") before do
end 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)
it "has the correct label" do allow(form).to receive(:start_year_2025_or_later?).and_return(true)
expect(household_characteristics.label).to eq("Household characteristics")
end end
it "has correct depends on" do it "has correct depends on" do
expect(household_characteristics.depends_on).to eq([{ "setup_completed?" => true, "company_buyer?" => false }]) expect(household_characteristics.depends_on).to eq([{ "setup_completed?" => true }])
end end
context "when the sale is to a company buyer" do it "has correct pages" do
let(:log) { FactoryBot.build(:sales_log, ownershipsch: 3, companybuy: 1) } expect(household_characteristics.pages.map(&:id)).to eq(
%w[
it "is not displayed in tasklist" do buyer_1_age
expect(household_characteristics.displayed_in_tasklist?(log)).to eq(false) age_1_retirement_value_check
end age_1_not_retired_value_check
end age_1_old_persons_shared_ownership_joint_purchase_value_check
age_1_old_persons_shared_ownership_value_check
context "when the sale is not to a company buyer" do buyer_1_gender_identity
let(:log) { FactoryBot.build(:sales_log, ownershipsch: 3, companybuy: 2) } buyer_1_ethnic_group
buyer_1_ethnic_background_black
it "is displayed in tasklist" do buyer_1_ethnic_background_asian
expect(household_characteristics.displayed_in_tasklist?(log)).to eq(true) 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_min_value_check
buyer_1_live_in_property
buyer_1_live_in_property_value_check
buyer_2_relationship_to_buyer_1
buyer_2_relationship_student_not_child_value_check
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_age_student_not_child_value_check
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_min_value_check
buyer_2_working_situation_student_not_child_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
relationship_2_student_not_child_value_check
person_2_age
age_2_retirement_value_check
age_2_not_retired_value_check
age_2_student_not_child_value_check
age_2_partner_under_16_value_check
person_2_gender_identity
person_2_working_situation
working_situation_2_retirement_value_check
working_situation_2_not_retired_value_check
working_situation_2_student_not_child_value_check
person_3_known
person_3_relationship_to_buyer_1
relationship_3_partner_under_16_value_check
relationship_3_multiple_partners_value_check
relationship_3_student_not_child_value_check
person_3_age
age_3_retirement_value_check
age_3_not_retired_value_check
age_3_student_not_child_value_check
age_3_partner_under_16_value_check
person_3_gender_identity
person_3_working_situation
working_situation_3_retirement_value_check
working_situation_3_not_retired_value_check
working_situation_3_student_not_child_value_check
person_4_known
person_4_relationship_to_buyer_1
relationship_4_partner_under_16_value_check
relationship_4_multiple_partners_value_check
relationship_4_student_not_child_value_check
person_4_age
age_4_retirement_value_check
age_4_not_retired_value_check
age_4_student_not_child_value_check
age_4_partner_under_16_value_check
person_4_gender_identity
person_4_working_situation
working_situation_4_retirement_value_check
working_situation_4_not_retired_value_check
working_situation_4_student_not_child_value_check
person_5_known
person_5_relationship_to_buyer_1
relationship_5_partner_under_16_value_check
relationship_5_multiple_partners_value_check
relationship_5_student_not_child_value_check
person_5_age
age_5_retirement_value_check
age_5_not_retired_value_check
age_5_student_not_child_value_check
age_5_partner_under_16_value_check
person_5_gender_identity
person_5_working_situation
working_situation_5_retirement_value_check
working_situation_5_not_retired_value_check
working_situation_5_student_not_child_value_check
person_6_known
person_6_relationship_to_buyer_1
relationship_6_partner_under_16_value_check
relationship_6_multiple_partners_value_check
relationship_6_student_not_child_value_check
person_6_age
age_6_retirement_value_check
age_6_not_retired_value_check
age_6_student_not_child_value_check
age_6_partner_under_16_value_check
person_6_gender_identity
person_6_working_situation
working_situation_6_retirement_value_check
working_situation_6_not_retired_value_check
working_situation_6_student_not_child_value_check
],
)
end end
end end
end end

Loading…
Cancel
Save