diff --git a/app/models/form/sales/questions/joint_purchase.rb b/app/models/form/sales/questions/joint_purchase.rb index 3de66ae1e..88672541d 100644 --- a/app/models/form/sales/questions/joint_purchase.rb +++ b/app/models/form/sales/questions/joint_purchase.rb @@ -13,4 +13,10 @@ class Form::Sales::Questions::JointPurchase < ::Form::Question "1" => { "value" => "Yes" }, "2" => { "value" => "No" }, }.freeze + + def hint_text + if form.start_year_after_2024? + "This is where two or more people are named as legal owners of the property after the purchase" + end + end end diff --git a/spec/models/form/sales/questions/joint_purchase_spec.rb b/spec/models/form/sales/questions/joint_purchase_spec.rb index 5d738531c..fcd3b72e5 100644 --- a/spec/models/form/sales/questions/joint_purchase_spec.rb +++ b/spec/models/form/sales/questions/joint_purchase_spec.rb @@ -6,6 +6,13 @@ RSpec.describe Form::Sales::Questions::JointPurchase, type: :model do 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) } + + 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) @@ -31,14 +38,30 @@ RSpec.describe Form::Sales::Questions::JointPurchase, type: :model do expect(question.derived?).to be false end - it "has the correct hint_text" do - expect(question.hint_text).to be_nil - end - it "has the correct answer_options" do expect(question.answer_options).to eq({ "1" => { "value" => "Yes" }, "2" => { "value" => "No" }, }) end + + context "with collection year before 2024" do + before do + allow(form).to receive(:start_year_after_2024?).and_return(false) + end + + it "has the blank hint_text" do + expect(question.hint_text).to be_nil + end + end + + context "with collection year >= 2024" do + before do + allow(form).to receive(:start_year_after_2024?).and_return(true) + end + + it "has the correct hint_text" do + expect(question.hint_text).to eq("This is where two or more people are named as legal owners of the property after the purchase") + end + end end