From 18f0c1dff91a0a3efc4dc96cbc3052e2207ee830 Mon Sep 17 00:00:00 2001 From: Rachael Booth Date: Fri, 26 Jan 2024 16:58:19 +0000 Subject: [PATCH] CLDC-3163: Add hint text for joint purchase question from 2024 (#2175) --- .../form/sales/questions/joint_purchase.rb | 6 ++++ .../sales/questions/joint_purchase_spec.rb | 31 ++++++++++++++++--- 2 files changed, 33 insertions(+), 4 deletions(-) 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