From 0b8241500d7504338f49d719880777ae531a5c53 Mon Sep 17 00:00:00 2001 From: Jack S Date: Wed, 19 Apr 2023 13:08:55 +0100 Subject: [PATCH] CLDC-2229 Do not show hint text when outright sale --- .../form/sales/questions/purchase_price.rb | 12 ++++++-- .../sales/questions/purchase_price_spec.rb | 30 +++++++++++++++++++ 2 files changed, 39 insertions(+), 3 deletions(-) diff --git a/app/models/form/sales/questions/purchase_price.rb b/app/models/form/sales/questions/purchase_price.rb index c98a39ef3..ce9b58af6 100644 --- a/app/models/form/sales/questions/purchase_price.rb +++ b/app/models/form/sales/questions/purchase_price.rb @@ -8,17 +8,23 @@ class Form::Sales::Questions::PurchasePrice < ::Form::Question @min = 0 @width = 5 @prefix = "£" - @hint_text = "For all schemes, including Right to Acquire (RTA), Right to Buy (RTB), Voluntary Right to Buy (VRTB) or Preserved Right to Buy (PRTB) sales, enter the full price of the property without any discount" + @hint_text = hint_text @ownership_sch = ownershipsch @question_number = question_number end def question_number case @ownership_sch - when 2 + when 2 # discounted ownership scheme 100 - when 3 + when 3 # outright sale 110 end end + + def hint_text + return if @ownership_sch == 3 # outright sale + + "For all schemes, including Right to Acquire (RTA), Right to Buy (RTB), Voluntary Right to Buy (VRTB) or Preserved Right to Buy (PRTB) sales, enter the full price of the property without any discount" + end end diff --git a/spec/models/form/sales/questions/purchase_price_spec.rb b/spec/models/form/sales/questions/purchase_price_spec.rb index e9e7ee3c3..a6a4f6cbe 100644 --- a/spec/models/form/sales/questions/purchase_price_spec.rb +++ b/spec/models/form/sales/questions/purchase_price_spec.rb @@ -37,6 +37,36 @@ RSpec.describe Form::Sales::Questions::PurchasePrice, type: :model do ) end + it "has the correct question_number" do + expect(question.question_number).to be_nil + end + + context "when discounted ownership scheme" do + subject(:question) { described_class.new(question_id, question_definition, page, ownershipsch: 2) } + + it "has the correct hint" do + expect(question.hint_text).to eq( + "For all schemes, including Right to Acquire (RTA), Right to Buy (RTB), Voluntary Right to Buy (VRTB) or Preserved Right to Buy (PRTB) sales, enter the full price of the property without any discount", + ) + end + + it "has the correct question_number" do + expect(question.question_number).to eq(100) + end + end + + context "when outright sale" do + subject(:question) { described_class.new(question_id, question_definition, page, ownershipsch: 3) } + + it "has the correct hint" do + expect(question.hint_text).to be_nil + end + + it "has the correct question_number" do + expect(question.question_number).to eq(110) + end + end + it "has correct width" do expect(question.width).to eq(5) end