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 * 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 questionpull/1409/head
Arthur Campbell
2 years ago
committed by
GitHub
16 changed files with 329 additions and 54 deletions
@ -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 |
|
@ -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 |
@ -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 |
|
@ -1,4 +1,4 @@ |
|||||||
class Form::Lettings::Questions::Tenancylength < ::Form::Question |
class Form::Lettings::Questions::TenancyLength < ::Form::Question |
||||||
def initialize(id, hsh, page) |
def initialize(id, hsh, page) |
||||||
super |
super |
||||||
@id = "tenancylength" |
@id = "tenancylength" |
@ -1,4 +1,4 @@ |
|||||||
class Form::Lettings::Questions::Tenancyother < ::Form::Question |
class Form::Lettings::Questions::TenancyOther < ::Form::Question |
||||||
def initialize(id, hsh, page) |
def initialize(id, hsh, page) |
||||||
super |
super |
||||||
@id = "tenancyother" |
@id = "tenancyother" |
@ -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 |
@ -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 |
@ -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 |
@ -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 |
@ -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 |
@ -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 |
@ -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…
Reference in new issue