Browse Source
* Refactor log setup into code * Fix remaining tests * Revert schema changes * Add tests for setup section Co-authored-by: baarkerlounger <baarkerlounger@users.noreply.github.com> * rename spec Co-authored-by: Kat <katrina@madetech.com> Co-authored-by: baarkerlounger <baarkerlounger@users.noreply.github.com>pull/650/head
baarkerlounger
3 years ago
committed by
GitHub
53 changed files with 849 additions and 292 deletions
@ -0,0 +1,18 @@
|
||||
class Form::Setup::Pages::NeedsType < ::Form::Page |
||||
def initialize(id, hsh, subsection) |
||||
super |
||||
@id = "needs_type" |
||||
@header = "" |
||||
@description = "" |
||||
@questions = questions |
||||
@depends_on = [{ "supported_housing_schemes_enabled?" => true }] |
||||
@derived = true |
||||
@subsection = subsection |
||||
end |
||||
|
||||
def questions |
||||
[ |
||||
Form::Setup::Questions::NeedsType.new(nil, nil, self), |
||||
] |
||||
end |
||||
end |
@ -0,0 +1,16 @@
|
||||
class Form::Setup::Pages::PropertyReference < ::Form::Page |
||||
def initialize(id, hsh, subsection) |
||||
super |
||||
@id = "property_reference" |
||||
@header = "" |
||||
@description = "" |
||||
@questions = questions |
||||
@subsection = subsection |
||||
end |
||||
|
||||
def questions |
||||
[ |
||||
Form::Setup::Questions::PropertyReference.new(nil, nil, self), |
||||
] |
||||
end |
||||
end |
@ -0,0 +1,16 @@
|
||||
class Form::Setup::Pages::Renewal < ::Form::Page |
||||
def initialize(id, hsh, subsection) |
||||
super |
||||
@id = "renewal" |
||||
@header = "" |
||||
@description = "" |
||||
@questions = questions |
||||
@subsection = subsection |
||||
end |
||||
|
||||
def questions |
||||
[ |
||||
Form::Setup::Questions::Renewal.new(nil, nil, self), |
||||
] |
||||
end |
||||
end |
@ -0,0 +1,19 @@
|
||||
class Form::Setup::Pages::RentType < ::Form::Page |
||||
def initialize(id, hsh, subsection) |
||||
super |
||||
@id = "rent_type" |
||||
@header = "" |
||||
@description = "" |
||||
@questions = questions |
||||
@depends_on = [{ "supported_housing_schemes_enabled?" => true }] |
||||
@derived = true |
||||
@subsection = subsection |
||||
end |
||||
|
||||
def questions |
||||
[ |
||||
Form::Setup::Questions::RentType.new(nil, nil, self), |
||||
Form::Setup::Questions::IrproductOther.new(nil, nil, self), |
||||
] |
||||
end |
||||
end |
@ -0,0 +1,15 @@
|
||||
class Form::Setup::Pages::TenancyStartDate < ::Form::Page |
||||
def initialize(id, hsh, subsection) |
||||
super |
||||
@id = "tenancy_start_date" |
||||
@description = "" |
||||
@questions = questions |
||||
@subsection = subsection |
||||
end |
||||
|
||||
def questions |
||||
[ |
||||
Form::Setup::Questions::TenancyStartDate.new(nil, nil, self), |
||||
] |
||||
end |
||||
end |
@ -0,0 +1,16 @@
|
||||
class Form::Setup::Pages::TenantCode < ::Form::Page |
||||
def initialize(id, hsh, subsection) |
||||
super |
||||
@id = "tenant_code" |
||||
@header = "" |
||||
@description = "" |
||||
@questions = questions |
||||
@subsection = subsection |
||||
end |
||||
|
||||
def questions |
||||
[ |
||||
Form::Setup::Questions::TenantCode.new(nil, nil, self), |
||||
] |
||||
end |
||||
end |
@ -0,0 +1,10 @@
|
||||
class Form::Setup::Questions::IrproductOther < ::Form::Question |
||||
def initialize(id, hsh, page) |
||||
super |
||||
@id = "irproduct_other" |
||||
@check_answer_label = "Product name" |
||||
@header = "Name of rent product" |
||||
@type = "text" |
||||
@page = page |
||||
end |
||||
end |
@ -0,0 +1,17 @@
|
||||
class Form::Setup::Questions::NeedsType < ::Form::Question |
||||
def initialize(id, hsh, page) |
||||
super |
||||
@id = "needstype" |
||||
@check_answer_label = "Needs type" |
||||
@header = "What is the needs type?" |
||||
@hint_text = "" |
||||
@type = "radio" |
||||
@answer_options = ANSWER_OPTIONS |
||||
@page = page |
||||
end |
||||
|
||||
ANSWER_OPTIONS = { |
||||
"1" => { "value" => "General needs" }, |
||||
"2" => { "value" => "Supported housing" }, |
||||
}.freeze |
||||
end |
@ -0,0 +1,12 @@
|
||||
class Form::Setup::Questions::PropertyReference < ::Form::Question |
||||
def initialize(id, hsh, page) |
||||
super |
||||
@id = "propcode" |
||||
@check_answer_label = "Property reference" |
||||
@header = "What is the property reference?" |
||||
@hint_text = "This is how you usually refer to this property on your own systems." |
||||
@type = "text" |
||||
@width = 10 |
||||
@page = page |
||||
end |
||||
end |
@ -0,0 +1,17 @@
|
||||
class Form::Setup::Questions::Renewal < ::Form::Question |
||||
def initialize(id, hsh, page) |
||||
super |
||||
@id = "renewal" |
||||
@check_answer_label = "Property renewal" |
||||
@header = "Is this letting a renewal?" |
||||
@hint_text = "" |
||||
@type = "radio" |
||||
@answer_options = ANSWER_OPTIONS |
||||
@page = page |
||||
end |
||||
|
||||
ANSWER_OPTIONS = { |
||||
"1" => { "value" => "Yes" }, |
||||
"0" => { "value" => "No" }, |
||||
}.freeze |
||||
end |
@ -0,0 +1,22 @@
|
||||
class Form::Setup::Questions::RentType < ::Form::Question |
||||
def initialize(id, hsh, page) |
||||
super |
||||
@id = "rent_type" |
||||
@check_answer_label = "Rent type" |
||||
@header = "What is the rent type?" |
||||
@hint_text = "" |
||||
@type = "radio" |
||||
@answer_options = ANSWER_OPTIONS |
||||
@conditional_for = { "irproduct_other" => [5] } |
||||
@page = page |
||||
end |
||||
|
||||
ANSWER_OPTIONS = { |
||||
"1" => { "value" => "Affordable Rent" }, |
||||
"2" => { "value" => "London Affordable Rent" }, |
||||
"4" => { "value" => "London Living Rent" }, |
||||
"3" => { "value" => "Rent to Buy" }, |
||||
"0" => { "value" => "Social Rent" }, |
||||
"5" => { "value" => "Other intermediate rent product" }, |
||||
}.freeze |
||||
end |
@ -0,0 +1,10 @@
|
||||
class Form::Setup::Questions::TenancyStartDate < ::Form::Question |
||||
def initialize(id, hsh, page) |
||||
super |
||||
@id = "startdate" |
||||
@check_answer_label = "Tenancy start date" |
||||
@header = "What is the tenancy start date?" |
||||
@type = "date" |
||||
@page = page |
||||
end |
||||
end |
@ -0,0 +1,12 @@
|
||||
class Form::Setup::Questions::TenantCode < ::Form::Question |
||||
def initialize(id, hsh, page) |
||||
super |
||||
@id = "tenant_code" |
||||
@check_answer_label = "Tenant code" |
||||
@header = "What is the tenant code?" |
||||
@hint_text = "This is how you usually refer to this tenancy on your own systems." |
||||
@type = "text" |
||||
@width = 10 |
||||
@page = page |
||||
end |
||||
end |
@ -0,0 +1,10 @@
|
||||
class Form::Sections::Setup < ::Form::Section |
||||
def initialize(id, hsh, form) |
||||
super |
||||
@id = "setup" |
||||
@label = "Before you start" |
||||
@description = "" |
||||
@form = form |
||||
@subsections = [Form::Setup::Subsections::Setup.new(nil, nil, self)] |
||||
end |
||||
end |
@ -0,0 +1,20 @@
|
||||
class Form::Subsections::Setup < ::Form::Subsection |
||||
def initialize(id, hsh, section) |
||||
super |
||||
@id = "setup" |
||||
@label = "Set up this lettings log" |
||||
@pages = [pages] |
||||
@section = section |
||||
end |
||||
|
||||
def pages |
||||
[ |
||||
Form::Setup::Pages::NeedsType.new(nil, nil, self), |
||||
Form::Setup::Pages::Renewal.new(nil, nil, self), |
||||
Form::Setup::Pages::TenancyStartDate.new(nil, nil, self), |
||||
Form::Setup::Pages::RentType.new(nil, nil, self), |
||||
Form::Setup::Pages::TenantCode.new(nil, nil, self), |
||||
Form::Setup::Pages::PropertyReference.new(nil, nil, self), |
||||
] |
||||
end |
||||
end |
@ -1,138 +0,0 @@
|
||||
{ |
||||
"form_type": "setup", |
||||
"sections": { |
||||
"setup": { |
||||
"label": "Before you start", |
||||
"subsections": { |
||||
"setup": { |
||||
"label": "Set up this lettings log", |
||||
"pages": { |
||||
"needs_type": { |
||||
"header": "", |
||||
"description": "", |
||||
"questions": { |
||||
"needstype": { |
||||
"check_answer_label": "Needs type", |
||||
"header": "What is the needs type?", |
||||
"hint_text": "", |
||||
"type": "radio", |
||||
"answer_options": { |
||||
"1": { |
||||
"value": "General needs" |
||||
}, |
||||
"2": { |
||||
"value": "Supported housing" |
||||
} |
||||
} |
||||
} |
||||
}, |
||||
"derived": true, |
||||
"depends_on": [ |
||||
{ |
||||
"supported_housing_schemes_enabled?" : true |
||||
} |
||||
] |
||||
}, |
||||
"renewal": { |
||||
"header": "", |
||||
"description": "", |
||||
"questions": { |
||||
"renewal": { |
||||
"check_answer_label": "Property renewal", |
||||
"header": "Is this letting a renewal?", |
||||
"hint_text": "A renewal is a letting to the same tenant in the same property.", |
||||
"type": "radio", |
||||
"answer_options": { |
||||
"1": { |
||||
"value": "Yes" |
||||
}, |
||||
"0": { |
||||
"value": "No" |
||||
} |
||||
} |
||||
} |
||||
} |
||||
}, |
||||
"tenancy_start_date": { |
||||
"header": "", |
||||
"description": "", |
||||
"questions": { |
||||
"startdate": { |
||||
"check_answer_label": "Tenancy start date", |
||||
"header": "What is the tenancy start date?", |
||||
"type": "date" |
||||
} |
||||
} |
||||
}, |
||||
"rent_type": { |
||||
"header": "", |
||||
"description": "", |
||||
"questions": { |
||||
"rent_type": { |
||||
"check_answer_label": "Rent type", |
||||
"header": "What is the rent type?", |
||||
"hint_text": "", |
||||
"type": "radio", |
||||
"answer_options": { |
||||
"1": { |
||||
"value": "Affordable Rent" |
||||
}, |
||||
"2": { |
||||
"value": "London Affordable Rent" |
||||
}, |
||||
"4": { |
||||
"value": "London Living Rent" |
||||
}, |
||||
"3": { |
||||
"value": "Rent to Buy" |
||||
}, |
||||
"0": { |
||||
"value": "Social Rent" |
||||
}, |
||||
"5": { |
||||
"value": "Other intermediate rent product" |
||||
} |
||||
}, |
||||
"conditional_for": { |
||||
"irproduct_other": [5] |
||||
} |
||||
}, |
||||
"irproduct_other": { |
||||
"check_answer_label": "Product name", |
||||
"header": "Name of rent product", |
||||
"type": "text" |
||||
} |
||||
} |
||||
}, |
||||
"tenant_code": { |
||||
"header": "", |
||||
"description": "", |
||||
"questions": { |
||||
"tenant_code": { |
||||
"check_answer_label": "Tenant code", |
||||
"header": "What is the tenant code?", |
||||
"hint_text": "This is how you usually refer to this tenancy on your own systems.", |
||||
"type": "text", |
||||
"width": 10 |
||||
} |
||||
} |
||||
}, |
||||
"property_reference": { |
||||
"header": "", |
||||
"description": "", |
||||
"questions": { |
||||
"propcode": { |
||||
"check_answer_label": "Property reference", |
||||
"header": "What is the property reference?", |
||||
"hint_text": "This is how you usually refer to this property on your own systems.", |
||||
"type": "text", |
||||
"width": 10 |
||||
} |
||||
} |
||||
} |
||||
} |
||||
} |
||||
} |
||||
} |
||||
} |
||||
} |
@ -1,71 +0,0 @@
|
||||
{ |
||||
"form_type": "setup", |
||||
"sections": { |
||||
"setup": { |
||||
"label": "Before you start", |
||||
"subsections": { |
||||
"setup": { |
||||
"label": "Set up this lettings log", |
||||
"pages": { |
||||
"renewal": { |
||||
"header": "", |
||||
"description": "", |
||||
"questions": { |
||||
"renewal": { |
||||
"check_answer_label": "Property renewal", |
||||
"header": "Is this a renewal to the same tenant in the same property?", |
||||
"hint_text": "", |
||||
"type": "radio", |
||||
"answer_options": { |
||||
"1": "Yes", |
||||
"0": "No" |
||||
} |
||||
} |
||||
} |
||||
}, |
||||
"startdate": { |
||||
"header": "", |
||||
"description": "", |
||||
"questions": { |
||||
"startdate": { |
||||
"check_answer_label": "Tenancy start date", |
||||
"header": "What is the tenancy start date?", |
||||
"hint_text": "For example, 27 3 2007", |
||||
"type": "date" |
||||
} |
||||
} |
||||
}, |
||||
"about_this_letting": { |
||||
"header": "Tell us about this letting", |
||||
"description": "", |
||||
"questions": { |
||||
"rent_type": { |
||||
"check_answer_label": "Rent type", |
||||
"header": "What is the rent type?", |
||||
"hint_text": "", |
||||
"type": "radio", |
||||
"answer_options": { |
||||
"0": "Social rent", |
||||
"1": "Affordable rent", |
||||
"2": "London Affordable rent", |
||||
"3": "Rent to buy", |
||||
"4": "London living rent", |
||||
"5": "Other intermediate rent product" |
||||
}, |
||||
"conditional_for": { |
||||
"intermediate_rent_product_name": [5] |
||||
} |
||||
}, |
||||
"intermediate_rent_product_name": { |
||||
"check_answer_label": "Product name", |
||||
"header": "What is intermediate rent product name?", |
||||
"type": "text" |
||||
} |
||||
} |
||||
} |
||||
} |
||||
} |
||||
} |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,37 @@
|
||||
require "rails_helper" |
||||
|
||||
RSpec.describe Form::Setup::Pages::NeedsType, type: :model do |
||||
subject(:page) { described_class.new(page_id, page_definition, subsection) } |
||||
|
||||
let(:page_id) { nil } |
||||
let(:page_definition) { nil } |
||||
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[needstype]) |
||||
end |
||||
|
||||
it "has the correct id" do |
||||
expect(page.id).to eq("needs_type") |
||||
end |
||||
|
||||
it "has the correct header" do |
||||
expect(page.header).to eq("") |
||||
end |
||||
|
||||
it "has the correct description" do |
||||
expect(page.description).to eq("") |
||||
end |
||||
|
||||
it "has the correct depends_on" do |
||||
expect(page.depends_on).to eq([{ "supported_housing_schemes_enabled?" => true }]) |
||||
end |
||||
|
||||
it "has the correct derived" do |
||||
expect(page.derived).to be true |
||||
end |
||||
end |
@ -0,0 +1,37 @@
|
||||
require "rails_helper" |
||||
|
||||
RSpec.describe Form::Setup::Pages::PropertyReference, type: :model do |
||||
subject(:page) { described_class.new(page_id, page_definition, subsection) } |
||||
|
||||
let(:page_id) { nil } |
||||
let(:page_definition) { nil } |
||||
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[propcode]) |
||||
end |
||||
|
||||
it "has the correct id" do |
||||
expect(page.id).to eq("property_reference") |
||||
end |
||||
|
||||
it "has the correct header" do |
||||
expect(page.header).to eq("") |
||||
end |
||||
|
||||
it "has the correct description" do |
||||
expect(page.description).to eq("") |
||||
end |
||||
|
||||
it "has the correct depends_on" do |
||||
expect(page.depends_on).to be nil |
||||
end |
||||
|
||||
it "has the correct derived" do |
||||
expect(page.derived).to be nil |
||||
end |
||||
end |
@ -0,0 +1,37 @@
|
||||
require "rails_helper" |
||||
|
||||
RSpec.describe Form::Setup::Pages::Renewal, type: :model do |
||||
subject(:page) { described_class.new(page_id, page_definition, subsection) } |
||||
|
||||
let(:page_id) { nil } |
||||
let(:page_definition) { nil } |
||||
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[renewal]) |
||||
end |
||||
|
||||
it "has the correct id" do |
||||
expect(page.id).to eq("renewal") |
||||
end |
||||
|
||||
it "has the correct header" do |
||||
expect(page.header).to eq("") |
||||
end |
||||
|
||||
it "has the correct description" do |
||||
expect(page.description).to eq("") |
||||
end |
||||
|
||||
it "has the correct depends_on" do |
||||
expect(page.depends_on).to be nil |
||||
end |
||||
|
||||
it "has the correct derived" do |
||||
expect(page.derived).to be nil |
||||
end |
||||
end |
@ -0,0 +1,37 @@
|
||||
require "rails_helper" |
||||
|
||||
RSpec.describe Form::Setup::Pages::RentType, type: :model do |
||||
subject(:page) { described_class.new(page_id, page_definition, subsection) } |
||||
|
||||
let(:page_id) { nil } |
||||
let(:page_definition) { nil } |
||||
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[rent_type irproduct_other]) |
||||
end |
||||
|
||||
it "has the correct id" do |
||||
expect(page.id).to eq("rent_type") |
||||
end |
||||
|
||||
it "has the correct header" do |
||||
expect(page.header).to eq("") |
||||
end |
||||
|
||||
it "has the correct description" do |
||||
expect(page.description).to eq("") |
||||
end |
||||
|
||||
it "has the correct depends_on" do |
||||
expect(page.depends_on).to eq([{ "supported_housing_schemes_enabled?" => true }]) |
||||
end |
||||
|
||||
it "has the correct derived" do |
||||
expect(page.derived).to be true |
||||
end |
||||
end |
@ -0,0 +1,37 @@
|
||||
require "rails_helper" |
||||
|
||||
RSpec.describe Form::Setup::Pages::TenancyStartDate, type: :model do |
||||
subject(:page) { described_class.new(page_id, page_definition, subsection) } |
||||
|
||||
let(:page_id) { nil } |
||||
let(:page_definition) { nil } |
||||
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[startdate]) |
||||
end |
||||
|
||||
it "has the correct id" do |
||||
expect(page.id).to eq("tenancy_start_date") |
||||
end |
||||
|
||||
it "has the correct header" do |
||||
expect(page.header).to be nil |
||||
end |
||||
|
||||
it "has the correct description" do |
||||
expect(page.description).to eq("") |
||||
end |
||||
|
||||
it "has the correct depends_on" do |
||||
expect(page.depends_on).to be nil |
||||
end |
||||
|
||||
it "has the correct derived" do |
||||
expect(page.derived).to be nil |
||||
end |
||||
end |
@ -0,0 +1,37 @@
|
||||
require "rails_helper" |
||||
|
||||
RSpec.describe Form::Setup::Pages::TenantCode, type: :model do |
||||
subject(:page) { described_class.new(page_id, page_definition, subsection) } |
||||
|
||||
let(:page_id) { nil } |
||||
let(:page_definition) { nil } |
||||
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[tenant_code]) |
||||
end |
||||
|
||||
it "has the correct id" do |
||||
expect(page.id).to eq("tenant_code") |
||||
end |
||||
|
||||
it "has the correct header" do |
||||
expect(page.header).to eq("") |
||||
end |
||||
|
||||
it "has the correct description" do |
||||
expect(page.description).to eq("") |
||||
end |
||||
|
||||
it "has the correct depends_on" do |
||||
expect(page.depends_on).to be nil |
||||
end |
||||
|
||||
it "has the correct derived" do |
||||
expect(page.derived).to be nil |
||||
end |
||||
end |
@ -0,0 +1,29 @@
|
||||
require "rails_helper" |
||||
|
||||
RSpec.describe Form::Setup::Questions::IrproductOther, 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) } |
||||
|
||||
it "has correct page" do |
||||
expect(question.page).to eq(page) |
||||
end |
||||
|
||||
it "has the correct id" do |
||||
expect(question.id).to eq("irproduct_other") |
||||
end |
||||
|
||||
it "has the correct header" do |
||||
expect(question.header).to eq("Name of rent product") |
||||
end |
||||
|
||||
it "has the correct check_answer_label" do |
||||
expect(question.check_answer_label).to eq("Product name") |
||||
end |
||||
|
||||
it "has the correct type" do |
||||
expect(question.type).to eq("text") |
||||
end |
||||
end |
@ -0,0 +1,36 @@
|
||||
require "rails_helper" |
||||
|
||||
RSpec.describe Form::Setup::Questions::NeedsType, 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) } |
||||
|
||||
it "has correct page" do |
||||
expect(question.page).to eq(page) |
||||
end |
||||
|
||||
it "has the correct id" do |
||||
expect(question.id).to eq("needstype") |
||||
end |
||||
|
||||
it "has the correct header" do |
||||
expect(question.header).to eq("What is the needs type?") |
||||
end |
||||
|
||||
it "has the correct check_answer_label" do |
||||
expect(question.check_answer_label).to eq("Needs type") |
||||
end |
||||
|
||||
it "has the correct type" do |
||||
expect(question.type).to eq("radio") |
||||
end |
||||
|
||||
it "has the correct answer_options" do |
||||
expect(question.answer_options).to eq({ |
||||
"1" => { "value" => "General needs" }, |
||||
"2" => { "value" => "Supported housing" }, |
||||
}) |
||||
end |
||||
end |
@ -0,0 +1,37 @@
|
||||
require "rails_helper" |
||||
|
||||
RSpec.describe Form::Setup::Questions::PropertyReference, 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) } |
||||
|
||||
it "has correct page" do |
||||
expect(question.page).to eq(page) |
||||
end |
||||
|
||||
it "has the correct id" do |
||||
expect(question.id).to eq("propcode") |
||||
end |
||||
|
||||
it "has the correct header" do |
||||
expect(question.header).to eq("What is the property reference?") |
||||
end |
||||
|
||||
it "has the correct check_answer_label" do |
||||
expect(question.check_answer_label).to eq("Property reference") |
||||
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("This is how you usually refer to this property on your own systems.") |
||||
end |
||||
|
||||
it "has the correct width" do |
||||
expect(question.width).to eq(10) |
||||
end |
||||
end |
@ -0,0 +1,40 @@
|
||||
require "rails_helper" |
||||
|
||||
RSpec.describe Form::Setup::Questions::Renewal, 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) } |
||||
|
||||
it "has correct page" do |
||||
expect(question.page).to eq(page) |
||||
end |
||||
|
||||
it "has the correct id" do |
||||
expect(question.id).to eq("renewal") |
||||
end |
||||
|
||||
it "has the correct header" do |
||||
expect(question.header).to eq("Is this letting a renewal?") |
||||
end |
||||
|
||||
it "has the correct check_answer_label" do |
||||
expect(question.check_answer_label).to eq("Property renewal") |
||||
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 answer_options" do |
||||
expect(question.answer_options).to eq({ |
||||
"1" => { "value" => "Yes" }, |
||||
"0" => { "value" => "No" }, |
||||
}) |
||||
end |
||||
end |
@ -0,0 +1,48 @@
|
||||
require "rails_helper" |
||||
|
||||
RSpec.describe Form::Setup::Questions::RentType, 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) } |
||||
|
||||
it "has correct page" do |
||||
expect(question.page).to eq(page) |
||||
end |
||||
|
||||
it "has the correct id" do |
||||
expect(question.id).to eq("rent_type") |
||||
end |
||||
|
||||
it "has the correct header" do |
||||
expect(question.header).to eq("What is the rent type?") |
||||
end |
||||
|
||||
it "has the correct check_answer_label" do |
||||
expect(question.check_answer_label).to eq("Rent type") |
||||
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({ "irproduct_other" => [5] }) |
||||
end |
||||
|
||||
it "has the correct answer_options" do |
||||
expect(question.answer_options).to eq({ |
||||
"1" => { "value" => "Affordable Rent" }, |
||||
"2" => { "value" => "London Affordable Rent" }, |
||||
"4" => { "value" => "London Living Rent" }, |
||||
"3" => { "value" => "Rent to Buy" }, |
||||
"0" => { "value" => "Social Rent" }, |
||||
"5" => { "value" => "Other intermediate rent product" }, |
||||
}) |
||||
end |
||||
end |
@ -0,0 +1,29 @@
|
||||
require "rails_helper" |
||||
|
||||
RSpec.describe Form::Setup::Questions::TenancyStartDate, 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) } |
||||
|
||||
it "has correct page" do |
||||
expect(question.page).to eq(page) |
||||
end |
||||
|
||||
it "has the correct id" do |
||||
expect(question.id).to eq("startdate") |
||||
end |
||||
|
||||
it "has the correct header" do |
||||
expect(question.header).to eq("What is the tenancy start date?") |
||||
end |
||||
|
||||
it "has the correct check_answer_label" do |
||||
expect(question.check_answer_label).to eq("Tenancy start date") |
||||
end |
||||
|
||||
it "has the correct type" do |
||||
expect(question.type).to eq("date") |
||||
end |
||||
end |
@ -0,0 +1,37 @@
|
||||
require "rails_helper" |
||||
|
||||
RSpec.describe Form::Setup::Questions::TenantCode, 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) } |
||||
|
||||
it "has correct page" do |
||||
expect(question.page).to eq(page) |
||||
end |
||||
|
||||
it "has the correct id" do |
||||
expect(question.id).to eq("tenant_code") |
||||
end |
||||
|
||||
it "has the correct header" do |
||||
expect(question.header).to eq("What is the tenant code?") |
||||
end |
||||
|
||||
it "has the correct check_answer_label" do |
||||
expect(question.check_answer_label).to eq("Tenant code") |
||||
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("This is how you usually refer to this tenancy on your own systems.") |
||||
end |
||||
|
||||
it "has the correct width" do |
||||
expect(question.width).to eq(10) |
||||
end |
||||
end |
@ -0,0 +1,29 @@
|
||||
require "rails_helper" |
||||
|
||||
RSpec.describe Form::Setup::Sections::Setup, type: :model do |
||||
subject(:setup) { described_class.new(section_id, section_definition, form) } |
||||
|
||||
let(:section_id) { nil } |
||||
let(:section_definition) { nil } |
||||
let(:form) { instance_double(Form) } |
||||
|
||||
it "has correct form" do |
||||
expect(setup.form).to eq(form) |
||||
end |
||||
|
||||
it "has correct subsections" do |
||||
expect(setup.subsections.map(&:id)).to eq(%w[setup]) |
||||
end |
||||
|
||||
it "has the correct id" do |
||||
expect(setup.id).to eq("setup") |
||||
end |
||||
|
||||
it "has the correct label" do |
||||
expect(setup.label).to eq("Before you start") |
||||
end |
||||
|
||||
it "has the correct description" do |
||||
expect(setup.description).to eq("") |
||||
end |
||||
end |
@ -0,0 +1,25 @@
|
||||
require "rails_helper" |
||||
|
||||
RSpec.describe Form::Setup::Subsections::Setup, type: :model do |
||||
subject(:setup) { described_class.new(subsection_id, subsection_definition, section) } |
||||
|
||||
let(:subsection_id) { nil } |
||||
let(:subsection_definition) { nil } |
||||
let(:section) { instance_double(Form::Setup::Sections::Setup) } |
||||
|
||||
it "has correct section" do |
||||
expect(setup.section).to eq(section) |
||||
end |
||||
|
||||
it "has correct pages" do |
||||
expect(setup.pages.map(&:id)).to eq(%w[needs_type renewal tenancy_start_date rent_type tenant_code property_reference]) |
||||
end |
||||
|
||||
it "has the correct id" do |
||||
expect(setup.id).to eq("setup") |
||||
end |
||||
|
||||
it "has the correct label" do |
||||
expect(setup.label).to eq("Set up this lettings log") |
||||
end |
||||
end |
Loading…
Reference in new issue