Browse Source

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

pull/1341/head
Arthur Campbell 3 years ago
parent
commit
a7c99604b7
  1. 2
      app/models/form/lettings/pages/starter_tenancy_type.rb
  2. 2
      app/models/form/lettings/pages/tenancy_length.rb
  3. 4
      app/models/form/lettings/pages/tenancy_type.rb
  4. 22
      app/models/form/lettings/questions/tenancy.rb
  5. 2
      app/models/form/lettings/questions/tenancy_length.rb
  6. 2
      app/models/form/lettings/questions/tenancy_other.rb
  7. 37
      app/models/form/lettings/questions/tenancy_type.rb
  8. 44
      spec/models/form/lettings/questions/tenancy_length_spec.rb
  9. 35
      spec/models/form/lettings/questions/tenancy_other_spec.rb
  10. 65
      spec/models/form/lettings/questions/tenancy_type_spec.rb

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

@ -8,7 +8,7 @@ class Form::Lettings::Pages::StarterTenancyType < ::Form::Page
def questions
@questions ||= [
Form::Lettings::Questions::StarterTenancy.new(nil, nil, self),
Form::Lettings::Questions::Tenancyother.new(nil, nil, self),
Form::Lettings::Questions::TenancyOther.new(nil, nil, self),
]
end
end

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

@ -6,6 +6,6 @@ class Form::Lettings::Pages::TenancyLength < ::Form::Page
end
def questions
@questions ||= [Form::Lettings::Questions::Tenancylength.new(nil, nil, self)]
@questions ||= [Form::Lettings::Questions::TenancyLength.new(nil, nil, self)]
end
end

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

@ -7,8 +7,8 @@ class Form::Lettings::Pages::TenancyType < ::Form::Page
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/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

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