Browse Source

CLDC-1816 add hint text to tenancy type options (#1341)

* add hint text to several options on tenancy type, rename question class and a few others to make them pascal case and write test files for all changed questions

* update some depends on for readability and write test files for page classes

* change the condition to avoid conflicts with 2034 and cover that ticket in this one

* also add hints to other tenancy question
pull/1409/head
Arthur Campbell 2 years ago committed by GitHub
parent
commit
92fdc0fff1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 6
      app/models/form/lettings/pages/starter_tenancy_type.rb
  2. 4
      app/models/form/lettings/pages/tenancy_length.rb
  3. 6
      app/models/form/lettings/pages/tenancy_type.rb
  4. 22
      app/models/form/lettings/questions/starter_tenancy.rb
  5. 37
      app/models/form/lettings/questions/starter_tenancy_type.rb
  6. 22
      app/models/form/lettings/questions/tenancy.rb
  7. 2
      app/models/form/lettings/questions/tenancy_length.rb
  8. 2
      app/models/form/lettings/questions/tenancy_other.rb
  9. 37
      app/models/form/lettings/questions/tenancy_type.rb
  10. 8
      app/models/lettings_log.rb
  11. 31
      spec/models/form/lettings/pages/starter_tenancy_type_spec.rb
  12. 31
      spec/models/form/lettings/pages/tenancy_length_spec.rb
  13. 31
      spec/models/form/lettings/pages/tenancy_type_spec.rb
  14. 44
      spec/models/form/lettings/questions/tenancy_length_spec.rb
  15. 35
      spec/models/form/lettings/questions/tenancy_other_spec.rb
  16. 65
      spec/models/form/lettings/questions/tenancy_type_spec.rb

6
app/models/form/lettings/pages/starter_tenancy_type.rb

@ -2,13 +2,13 @@ class Form::Lettings::Pages::StarterTenancyType < ::Form::Page
def initialize(id, hsh, subsection)
super
@id = "starter_tenancy_type"
@depends_on = [{ "startertenancy" => 1 }]
@depends_on = [{ "starter_tenancy?" => true }]
end
def questions
@questions ||= [
Form::Lettings::Questions::StarterTenancy.new(nil, nil, self),
Form::Lettings::Questions::Tenancyother.new(nil, nil, self),
Form::Lettings::Questions::StarterTenancyType.new(nil, nil, self),
Form::Lettings::Questions::TenancyOther.new(nil, nil, self),
]
end
end

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

@ -2,10 +2,10 @@ class Form::Lettings::Pages::TenancyLength < ::Form::Page
def initialize(id, hsh, subsection)
super
@id = "tenancy_length"
@depends_on = [{ "tenancy" => 4 }, { "tenancy" => 6 }, { "tenancy" => 3 }]
@depends_on = [{ "tenancy_type_fixed_term?" => true }]
end
def questions
@questions ||= [Form::Lettings::Questions::Tenancylength.new(nil, nil, self)]
@questions ||= [Form::Lettings::Questions::TenancyLength.new(nil, nil, self)]
end
end

6
app/models/form/lettings/pages/tenancy_type.rb

@ -2,13 +2,13 @@ class Form::Lettings::Pages::TenancyType < ::Form::Page
def initialize(id, hsh, subsection)
super
@id = "tenancy_type"
@depends_on = [{ "startertenancy" => 2 }]
@depends_on = [{ "starter_tenancy?" => false }]
end
def questions
@questions ||= [
Form::Lettings::Questions::Tenancy.new(nil, nil, self),
Form::Lettings::Questions::Tenancyother.new(nil, nil, self),
Form::Lettings::Questions::TenancyType.new(nil, nil, self),
Form::Lettings::Questions::TenancyOther.new(nil, nil, self),
]
end
end

22
app/models/form/lettings/questions/starter_tenancy.rb

@ -1,22 +0,0 @@
class Form::Lettings::Questions::StarterTenancy < ::Form::Question
def initialize(id, hsh, page)
super
@id = "tenancy"
@check_answer_label = "Type of main tenancy after the starter period has ended?"
@header = "What is the type of tenancy after the starter period has ended?"
@type = "radio"
@check_answers_card_number = 0
@hint_text = "This is also known as an ‘introductory period’."
@answer_options = ANSWER_OPTIONS
@conditional_for = { "tenancyother" => [3] }
end
ANSWER_OPTIONS = {
"4" => { "value" => "Assured Shorthold Tenancy (AST) – Fixed term" },
"6" => { "value" => "Secure – fixed term" },
"2" => { "value" => "Assured – lifetime" },
"7" => { "value" => "Secure – lifetime" },
"5" => { "value" => "Licence agreement" },
"3" => { "value" => "Other" },
}.freeze
end

37
app/models/form/lettings/questions/starter_tenancy_type.rb

@ -0,0 +1,37 @@
class Form::Lettings::Questions::StarterTenancyType < ::Form::Question
def initialize(id, hsh, page)
super
@id = "tenancy"
@check_answer_label = "Type of main tenancy after the starter period has ended?"
@header = "What is the type of tenancy after the starter period has ended?"
@type = "radio"
@check_answers_card_number = 0
@hint_text = "This is also known as an ‘introductory period’."
@answer_options = ANSWER_OPTIONS
@conditional_for = { "tenancyother" => [3] }
end
ANSWER_OPTIONS = {
"4" => {
"value" => "Assured Shorthold Tenancy (AST) – Fixed term",
"hint" => "Mostly housing associations provide these. Fixed term tenancies are intended to be for a set amount of time up to 20 years.",
},
"6" => {
"value" => "Secure – fixed term",
"hint" => "Mostly local authorities provide these. Fixed term tenancies are intended to be for a set amount of time up to 20 years.",
},
"2" => {
"value" => "Assured – lifetime",
},
"7" => {
"value" => "Secure – lifetime",
},
"5" => {
"value" => "Licence agreement",
"hint" => "Licence agreements are mostly used for Supported Housing and work on a rolling basis.",
},
"3" => {
"value" => "Other",
},
}.freeze
end

22
app/models/form/lettings/questions/tenancy.rb

@ -1,22 +0,0 @@
class Form::Lettings::Questions::Tenancy < ::Form::Question
def initialize(id, hsh, page)
super
@id = "tenancy"
@check_answer_label = "Type of main tenancy"
@header = "What is the type of tenancy?"
@type = "radio"
@check_answers_card_number = 0
@hint_text = ""
@answer_options = ANSWER_OPTIONS
@conditional_for = { "tenancyother" => [3] }
end
ANSWER_OPTIONS = {
"4" => { "value" => "Assured Shorthold Tenancy (AST) – Fixed term" },
"6" => { "value" => "Secure – fixed term" },
"2" => { "value" => "Assured – lifetime" },
"7" => { "value" => "Secure – lifetime" },
"5" => { "value" => "Licence agreement" },
"3" => { "value" => "Other" },
}.freeze
end

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

@ -1,4 +1,4 @@
class Form::Lettings::Questions::Tenancylength < ::Form::Question
class Form::Lettings::Questions::TenancyLength < ::Form::Question
def initialize(id, hsh, page)
super
@id = "tenancylength"

2
app/models/form/lettings/questions/tenancyother.rb → app/models/form/lettings/questions/tenancy_other.rb

@ -1,4 +1,4 @@
class Form::Lettings::Questions::Tenancyother < ::Form::Question
class Form::Lettings::Questions::TenancyOther < ::Form::Question
def initialize(id, hsh, page)
super
@id = "tenancyother"

37
app/models/form/lettings/questions/tenancy_type.rb

@ -0,0 +1,37 @@
class Form::Lettings::Questions::TenancyType < ::Form::Question
def initialize(id, hsh, page)
super
@id = "tenancy"
@check_answer_label = "Type of main tenancy"
@header = "What is the type of tenancy?"
@type = "radio"
@check_answers_card_number = 0
@hint_text = ""
@answer_options = ANSWER_OPTIONS
@conditional_for = { "tenancyother" => [3] }
end
ANSWER_OPTIONS = {
"4" => {
"value" => "Assured Shorthold Tenancy (AST) – Fixed term",
"hint" => "Mostly housing associations provide these. Fixed term tenancies are intended to be for a set amount of time up to 20 years.",
},
"6" => {
"value" => "Secure – fixed term",
"hint" => "Mostly local authorities provide these. Fixed term tenancies are intended to be for a set amount of time up to 20 years.",
},
"2" => {
"value" => "Assured – lifetime",
},
"7" => {
"value" => "Secure – lifetime",
},
"5" => {
"value" => "Licence agreement",
"hint" => "Licence agreements are mostly used for Supported Housing and work on a rolling basis.",
},
"3" => {
"value" => "Other",
},
}.freeze
end

8
app/models/lettings_log.rb

@ -195,6 +195,14 @@ class LettingsLog < Log
renewal == 1
end
def starter_tenancy?
startertenancy == 1
end
def tenancy_type_fixed_term?
[4, 6].include? tenancy
end
def is_general_needs?
# 1: General Needs
needstype == 1

31
spec/models/form/lettings/pages/starter_tenancy_type_spec.rb

@ -0,0 +1,31 @@
require "rails_helper"
RSpec.describe Form::Lettings::Pages::StarterTenancyType, type: :model do
subject(:page) { described_class.new(nil, nil, subsection) }
let(:subsection) { instance_double(Form::Subsection) }
it "has correct subsection" do
expect(page.subsection).to eq(subsection)
end
it "has correct questions" do
expect(page.questions.map(&:id)).to eq(%w[tenancy tenancyother])
end
it "has the correct id" do
expect(page.id).to eq("starter_tenancy_type")
end
it "has the correct header" do
expect(page.header).to be_nil
end
it "has the correct description" do
expect(page.description).to be_nil
end
it "has the correct depends_on" do
expect(page.depends_on).to eq([{ "starter_tenancy?" => true }])
end
end

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

@ -0,0 +1,31 @@
require "rails_helper"
RSpec.describe Form::Lettings::Pages::TenancyLength, type: :model do
subject(:page) { described_class.new(nil, nil, subsection) }
let(:subsection) { instance_double(Form::Subsection) }
it "has correct subsection" do
expect(page.subsection).to eq subsection
end
it "has correct questions" do
expect(page.questions.map(&:id)).to eq %w[tenancylength]
end
it "has the correct id" do
expect(page.id).to eq "tenancy_length"
end
it "has the correct header" do
expect(page.header).to be_nil
end
it "has the correct description" do
expect(page.description).to be_nil
end
it "has the correct depends_on" do
expect(page.depends_on).to eq [{ "tenancy_type_fixed_term?" => true }]
end
end

31
spec/models/form/lettings/pages/tenancy_type_spec.rb

@ -0,0 +1,31 @@
require "rails_helper"
RSpec.describe Form::Lettings::Pages::TenancyType, type: :model do
subject(:page) { described_class.new(nil, nil, subsection) }
let(:subsection) { instance_double(Form::Subsection) }
it "has correct subsection" do
expect(page.subsection).to eq(subsection)
end
it "has correct questions" do
expect(page.questions.map(&:id)).to eq %w[tenancy tenancyother]
end
it "has the correct id" do
expect(page.id).to eq "tenancy_type"
end
it "has the correct header" do
expect(page.header).to be_nil
end
it "has the correct description" do
expect(page.description).to be_nil
end
it "has the correct depends_on" do
expect(page.depends_on).to eq [{ "starter_tenancy?" => false }]
end
end

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

@ -0,0 +1,44 @@
require "rails_helper"
RSpec.describe Form::Lettings::Questions::TenancyLength, type: :model do
subject(:question) { described_class.new(nil, nil, page) }
let(:page) { instance_double(Form::Page) }
it "has correct page" do
expect(question.page).to eq(page)
end
it "has the correct id" do
expect(question.id).to eq("tenancylength")
end
it "has the correct header" do
expect(question.header).to eq("What is the length of the fixed-term tenancy to the nearest year?")
end
it "has the correct check_answer_label" do
expect(question.check_answer_label).to eq("Length of fixed-term tenancy")
end
it "has the correct type" do
expect(question.type).to eq("numeric")
end
it "has the correct hint_text" do
expect(question.hint_text).to eq("Don’t include the starter or introductory period.")
end
it "has the correct minimum and maximum" do
expect(question.min).to eq 0
expect(question.max).to eq 150
end
it "has the correct step" do
expect(question.step).to eq 1
end
it "is not marked as derived" do
expect(question.derived?).to be false
end
end

35
spec/models/form/lettings/questions/tenancy_other_spec.rb

@ -0,0 +1,35 @@
require "rails_helper"
RSpec.describe Form::Lettings::Questions::TenancyOther, type: :model do
subject(:question) { described_class.new(nil, nil, page) }
let(:page) { instance_double(Form::Page) }
it "has correct page" do
expect(question.page).to eq(page)
end
it "has the correct id" do
expect(question.id).to eq("tenancyother")
end
it "has the correct header" do
expect(question.header).to eq("Please state the tenancy type")
end
it "has the correct check_answer_label" do
expect(question.check_answer_label).to eq("")
end
it "has the correct type" do
expect(question.type).to eq("text")
end
it "has the correct hint_text" do
expect(question.hint_text).to eq("")
end
it "is not marked as derived" do
expect(question.derived?).to be false
end
end

65
spec/models/form/lettings/questions/tenancy_type_spec.rb

@ -0,0 +1,65 @@
require "rails_helper"
RSpec.describe Form::Lettings::Questions::TenancyType, type: :model do
subject(:question) { described_class.new(nil, nil, page) }
let(:page) { instance_double(Form::Page) }
it "has correct page" do
expect(question.page).to eq(page)
end
it "has the correct id" do
expect(question.id).to eq("tenancy")
end
it "has the correct header" do
expect(question.header).to eq("What is the type of tenancy?")
end
it "has the correct check_answer_label" do
expect(question.check_answer_label).to eq("Type of main tenancy")
end
it "has the correct type" do
expect(question.type).to eq("radio")
end
it "has the correct hint_text" do
expect(question.hint_text).to eq("")
end
it "has the correct conditional_for" do
expect(question.conditional_for).to eq({ "tenancyother" => [3] })
end
it "has the correct answer_options" do
expect(question.answer_options).to eq({
"4" => {
"value" => "Assured Shorthold Tenancy (AST) – Fixed term",
"hint" => "Mostly housing associations provide these. Fixed term tenancies are intended to be for a set amount of time up to 20 years.",
},
"6" => {
"value" => "Secure – fixed term",
"hint" => "Mostly local authorities provide these. Fixed term tenancies are intended to be for a set amount of time up to 20 years.",
},
"2" => {
"value" => "Assured – lifetime",
},
"7" => {
"value" => "Secure – lifetime",
},
"5" => {
"value" => "Licence agreement",
"hint" => "Licence agreements are mostly used for Supported Housing and work on a rolling basis.",
},
"3" => {
"value" => "Other",
},
})
end
it "is not marked as derived" do
expect(question.derived?).to be false
end
end
Loading…
Cancel
Save