Browse Source

CLDC-2229 Do not show hint text when outright sale (#1563)

pull/1567/head
Jack 2 years ago committed by GitHub
parent
commit
55b6b8d951
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 12
      app/models/form/sales/questions/purchase_price.rb
  2. 30
      spec/models/form/sales/questions/purchase_price_spec.rb

12
app/models/form/sales/questions/purchase_price.rb

@ -8,17 +8,23 @@ class Form::Sales::Questions::PurchasePrice < ::Form::Question
@min = 0 @min = 0
@width = 5 @width = 5
@prefix = "£" @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 @ownership_sch = ownershipsch
@question_number = question_number @question_number = question_number
end end
def question_number def question_number
case @ownership_sch case @ownership_sch
when 2 when 2 # discounted ownership scheme
100 100
when 3 when 3 # outright sale
110 110
end end
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 end

30
spec/models/form/sales/questions/purchase_price_spec.rb

@ -37,6 +37,36 @@ RSpec.describe Form::Sales::Questions::PurchasePrice, type: :model do
) )
end 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 it "has correct width" do
expect(question.width).to eq(5) expect(question.width).to eq(5)
end end

Loading…
Cancel
Save