Browse Source
* feat: update answer options and hint text for 24/25 * feat: update answer options and hint text, add new period tenancy length question and test * feat: update tests * feat: update tests * feat: update tests * Update header and CYA label * Remove fixed term tenancy validation for periodic * Validate periodic tenancy length --------- Co-authored-by: Kat <katrina@kosiak.co.uk>pull/2239/head
natdeanlewissoftwire
10 months ago
committed by
GitHub
14 changed files with 498 additions and 82 deletions
@ -0,0 +1,11 @@ |
|||||||
|
class Form::Lettings::Pages::TenancyLengthPeriodic < ::Form::Page |
||||||
|
def initialize(id, hsh, subsection) |
||||||
|
super |
||||||
|
@id = "tenancy_length_periodic" |
||||||
|
@depends_on = [{ "tenancy_type_periodic?" => true }] |
||||||
|
end |
||||||
|
|
||||||
|
def questions |
||||||
|
@questions ||= [Form::Lettings::Questions::TenancyLengthPeriodic.new(nil, nil, self)] |
||||||
|
end |
||||||
|
end |
@ -0,0 +1,16 @@ |
|||||||
|
class Form::Lettings::Questions::TenancyLengthPeriodic < ::Form::Question |
||||||
|
def initialize(id, hsh, page) |
||||||
|
super |
||||||
|
@id = "tenancylength" |
||||||
|
@check_answer_label = "Length of periodic tenancy" |
||||||
|
@header = "What is the length of the periodic tenancy to the nearest year?" |
||||||
|
@type = "numeric" |
||||||
|
@width = 2 |
||||||
|
@check_answers_card_number = 0 |
||||||
|
@max = 150 |
||||||
|
@min = 0 |
||||||
|
@step = 1 |
||||||
|
@question_number = 28 |
||||||
|
@hint_text = "As this is a periodic tenancy, this question is optional. If you do not have the information available click save and continue" |
||||||
|
end |
||||||
|
end |
@ -0,0 +1,31 @@ |
|||||||
|
require "rails_helper" |
||||||
|
|
||||||
|
RSpec.describe Form::Lettings::Pages::TenancyLengthPeriodic, 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_periodic" |
||||||
|
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_periodic?" => true }] |
||||||
|
end |
||||||
|
end |
@ -0,0 +1,112 @@ |
|||||||
|
require "rails_helper" |
||||||
|
|
||||||
|
RSpec.describe Form::Lettings::Questions::StarterTenancyType, type: :model do |
||||||
|
subject(:question) { described_class.new(question_id, question_definition, page) } |
||||||
|
|
||||||
|
let(:question_id) { nil } |
||||||
|
let(:question_definition) { nil } |
||||||
|
let(:page) { instance_double(Form::Page) } |
||||||
|
let(:subsection) { instance_double(Form::Subsection) } |
||||||
|
let(:form) { instance_double(Form) } |
||||||
|
|
||||||
|
before do |
||||||
|
allow(page).to receive(:subsection).and_return(subsection) |
||||||
|
allow(subsection).to receive(:form).and_return(form) |
||||||
|
end |
||||||
|
|
||||||
|
context "with 2023/24 form" do |
||||||
|
before do |
||||||
|
allow(form).to receive(:start_year_after_2024?).and_return(false) |
||||||
|
end |
||||||
|
|
||||||
|
it "has the correct check answer label" do |
||||||
|
expect(question.check_answer_label).to eq("Type of main tenancy after the starter period has ended") |
||||||
|
end |
||||||
|
|
||||||
|
it "has the correct hint_text" do |
||||||
|
expect(question.hint_text).to eq("This is also known as an ‘introductory period’.") |
||||||
|
end |
||||||
|
|
||||||
|
it "has the correct header" do |
||||||
|
expect(question.header).to eq("What is the type of tenancy after the starter period has ended?") |
||||||
|
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 |
||||||
|
end |
||||||
|
|
||||||
|
context "with 2024/25 form" do |
||||||
|
before do |
||||||
|
allow(form).to receive(:start_year_after_2024?).and_return(true) |
||||||
|
end |
||||||
|
|
||||||
|
it "has the correct check answer label" do |
||||||
|
expect(question.check_answer_label).to eq("Type of main tenancy after the starter or introductory period has ended") |
||||||
|
end |
||||||
|
|
||||||
|
it "has the correct updated hint_text" do |
||||||
|
expect(question.hint_text).to eq("") |
||||||
|
end |
||||||
|
|
||||||
|
it "has the correct header" do |
||||||
|
expect(question.header).to eq("What is the type of tenancy after the starter or introductory period has ended?") |
||||||
|
end |
||||||
|
|
||||||
|
it "has the correct answer options" do |
||||||
|
expect(question.answer_options).to eq( |
||||||
|
{ |
||||||
|
"4" => { |
||||||
|
"value" => "Assured Shorthold Tenancy (AST) – Fixed term", |
||||||
|
"hint" => "These are mostly provided by housing associations. Fixed term tenancies are intended to be for a set amount of time up to 20 years.", |
||||||
|
}, |
||||||
|
"6" => { |
||||||
|
"value" => "Secure – fixed term", |
||||||
|
"hint" => "These are mostly provided by local authorities. 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", |
||||||
|
}, |
||||||
|
"8" => { |
||||||
|
"value" => "Periodic", |
||||||
|
"hint" => "These are rolling tenancies with no fixed end date. They may have an initial fixed term and then become rolling.", |
||||||
|
}, |
||||||
|
"5" => { |
||||||
|
"value" => "Licence agreement", |
||||||
|
"hint" => "These are mostly used for Supported Housing and work on a rolling basis.", |
||||||
|
}, |
||||||
|
"3" => { |
||||||
|
"value" => "Other", |
||||||
|
}, |
||||||
|
}, |
||||||
|
) |
||||||
|
end |
||||||
|
end |
||||||
|
end |
@ -0,0 +1,33 @@ |
|||||||
|
require "rails_helper" |
||||||
|
|
||||||
|
RSpec.describe Form::Lettings::Questions::TenancyLengthPeriodic, type: :model do |
||||||
|
subject(:question) { described_class.new(nil, nil, page) } |
||||||
|
|
||||||
|
let(:question_id) { nil } |
||||||
|
let(:question_definition) { nil } |
||||||
|
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 periodic tenancy to the nearest year?") |
||||||
|
end |
||||||
|
|
||||||
|
it "has the correct check_answer_label" do |
||||||
|
expect(question.check_answer_label).to eq("Length of periodic 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("As this is a periodic tenancy, this question is optional. If you do not have the information available click save and continue") |
||||||
|
end |
||||||
|
end |
Loading…
Reference in new issue