Browse Source

CLDC-3163: Add hint text for joint purchase question from 2024 (#2175)

CLDC-3152-update-ppostcode-hint-for-23-24 v0.4.11
Rachael Booth 11 months ago committed by GitHub
parent
commit
18f0c1dff9
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 6
      app/models/form/sales/questions/joint_purchase.rb
  2. 31
      spec/models/form/sales/questions/joint_purchase_spec.rb

6
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

31
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

Loading…
Cancel
Save