Browse Source

Set different hint texts for tenancy length (#2096)

pull/2100/head
kosiakkatrina 1 year ago committed by GitHub
parent
commit
d9a185f21f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      app/models/form/lettings/pages/tenancy_length.rb
  2. 11
      app/models/form/lettings/pages/tenancy_length_affordable_rent.rb
  3. 11
      app/models/form/lettings/pages/tenancy_length_intermediate_rent.rb
  4. 2
      app/models/form/lettings/questions/tenancy_length.rb
  5. 16
      app/models/form/lettings/questions/tenancy_length_affordable_rent.rb
  6. 16
      app/models/form/lettings/questions/tenancy_length_intermediate_rent.rb
  7. 2
      app/models/form/lettings/subsections/tenancy_information.rb
  8. 4
      app/models/lettings_log.rb
  9. 2
      spec/models/form/lettings/pages/tenancy_length_spec.rb
  10. 2
      spec/models/form/lettings/questions/tenancy_length_spec.rb
  11. 2
      spec/models/form/lettings/subsections/tenancy_information_spec.rb

2
app/models/form/lettings/pages/tenancy_length.rb

@ -2,7 +2,7 @@ class Form::Lettings::Pages::TenancyLength < ::Form::Page
def initialize(id, hsh, subsection) def initialize(id, hsh, subsection)
super super
@id = "tenancy_length" @id = "tenancy_length"
@depends_on = [{ "tenancy_type_fixed_term?" => true }] @depends_on = [{ "tenancy_type_fixed_term?" => true, "needstype" => 2 }]
end end
def questions def questions

11
app/models/form/lettings/pages/tenancy_length_affordable_rent.rb

@ -0,0 +1,11 @@
class Form::Lettings::Pages::TenancyLengthAffordableRent < ::Form::Page
def initialize(id, hsh, subsection)
super
@id = "tenancy_length_affordable_rent"
@depends_on = [{ "tenancy_type_fixed_term?" => true, "affordable_or_social_rent?" => true, "needstype" => 1 }]
end
def questions
@questions ||= [Form::Lettings::Questions::TenancyLengthAffordableRent.new(nil, nil, self)]
end
end

11
app/models/form/lettings/pages/tenancy_length_intermediate_rent.rb

@ -0,0 +1,11 @@
class Form::Lettings::Pages::TenancyLengthIntermediateRent < ::Form::Page
def initialize(id, hsh, subsection)
super
@id = "tenancy_length_intermediate_rent"
@depends_on = [{ "tenancy_type_fixed_term?" => true, "affordable_or_social_rent?" => false, "needstype" => 1 }]
end
def questions
@questions ||= [Form::Lettings::Questions::TenancyLengthIntermediateRent.new(nil, nil, self)]
end
end

2
app/models/form/lettings/questions/tenancy_length.rb

@ -9,7 +9,7 @@ class Form::Lettings::Questions::TenancyLength < ::Form::Question
@check_answers_card_number = 0 @check_answers_card_number = 0
@max = 150 @max = 150
@min = 0 @min = 0
@hint_text = "Don’t include the starter or introductory period." @hint_text = "Do not include the starter or introductory period."
@step = 1 @step = 1
@question_number = 28 @question_number = 28
end end

16
app/models/form/lettings/questions/tenancy_length_affordable_rent.rb

@ -0,0 +1,16 @@
class Form::Lettings::Questions::TenancyLengthAffordableRent < ::Form::Question
def initialize(id, hsh, page)
super
@id = "tenancylength"
@check_answer_label = "Length of fixed-term tenancy"
@header = "What is the length of the fixed-term tenancy to the nearest year?"
@type = "numeric"
@width = 2
@check_answers_card_number = 0
@max = 150
@min = 0
@hint_text = "Do not include the starter or introductory period.</br>The minimum period is 2 years for social or affordable rent general needs logs and you do not need a log for shorter tenancies."
@step = 1
@question_number = 28
end
end

16
app/models/form/lettings/questions/tenancy_length_intermediate_rent.rb

@ -0,0 +1,16 @@
class Form::Lettings::Questions::TenancyLengthIntermediateRent < ::Form::Question
def initialize(id, hsh, page)
super
@id = "tenancylength"
@check_answer_label = "Length of fixed-term tenancy"
@header = "What is the length of the fixed-term tenancy to the nearest year?"
@type = "numeric"
@width = 2
@check_answers_card_number = 0
@max = 150
@min = 0
@hint_text = "Do not include the starter or introductory period.</br>The minimum period is 1 year for intermediate rent general needs logs and you do not need a log for shorter tenancies."
@step = 1
@question_number = 28
end
end

2
app/models/form/lettings/subsections/tenancy_information.rb

@ -13,6 +13,8 @@ class Form::Lettings::Subsections::TenancyInformation < ::Form::Subsection
Form::Lettings::Pages::TenancyType.new(nil, nil, self), Form::Lettings::Pages::TenancyType.new(nil, nil, self),
Form::Lettings::Pages::StarterTenancyType.new(nil, nil, self), Form::Lettings::Pages::StarterTenancyType.new(nil, nil, self),
Form::Lettings::Pages::TenancyLength.new(nil, nil, self), Form::Lettings::Pages::TenancyLength.new(nil, nil, self),
Form::Lettings::Pages::TenancyLengthAffordableRent.new(nil, nil, self),
Form::Lettings::Pages::TenancyLengthIntermediateRent.new(nil, nil, self),
Form::Lettings::Pages::ShelteredAccommodation.new(nil, nil, self), Form::Lettings::Pages::ShelteredAccommodation.new(nil, nil, self),
].compact ].compact
end end

4
app/models/lettings_log.rb

@ -627,6 +627,10 @@ class LettingsLog < Log
letting_allocation_unknown letting_allocation_unknown
end end
def affordable_or_social_rent?
renttype == 1 || renttype == 2
end
private private
def reset_invalid_unresolved_log_fields! def reset_invalid_unresolved_log_fields!

2
spec/models/form/lettings/pages/tenancy_length_spec.rb

@ -26,6 +26,6 @@ RSpec.describe Form::Lettings::Pages::TenancyLength, type: :model do
end end
it "has the correct depends_on" do it "has the correct depends_on" do
expect(page.depends_on).to eq [{ "tenancy_type_fixed_term?" => true }] expect(page.depends_on).to eq [{ "tenancy_type_fixed_term?" => true, "needstype" => 2 }]
end end
end end

2
spec/models/form/lettings/questions/tenancy_length_spec.rb

@ -26,7 +26,7 @@ RSpec.describe Form::Lettings::Questions::TenancyLength, type: :model do
end end
it "has the correct hint_text" do it "has the correct hint_text" do
expect(question.hint_text).to eq("Don’t include the starter or introductory period.") expect(question.hint_text).to eq("Do not include the starter or introductory period.")
end end
it "has the correct minimum and maximum" do it "has the correct minimum and maximum" do

2
spec/models/form/lettings/subsections/tenancy_information_spec.rb

@ -13,7 +13,7 @@ RSpec.describe Form::Lettings::Subsections::TenancyInformation, type: :model do
it "has correct pages" do it "has correct pages" do
expect(tenancy_information.pages.map(&:id)).to eq( expect(tenancy_information.pages.map(&:id)).to eq(
%w[joint starter_tenancy tenancy_type starter_tenancy_type tenancy_length sheltered_accommodation], %w[joint starter_tenancy tenancy_type starter_tenancy_type tenancy_length tenancy_length_affordable_rent tenancy_length_intermediate_rent sheltered_accommodation],
) )
end end

Loading…
Cancel
Save