Browse Source
# Conflicts: # app/models/form/lettings/questions/starter_tenancy.rb # app/models/form/lettings/questions/tenancy.rb # app/models/form/sales/questions/other_nationality1.rbpull/1381/head
129 changed files with 5173 additions and 936 deletions
@ -1,23 +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] } |
||||
@question_number = 27 |
||||
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,23 +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] } |
||||
@question_number = 27 |
||||
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) |
||||
super |
||||
@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) |
||||
super |
||||
@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,11 @@
|
||||
class Form::Sales::Pages::Buyer2LivingIn < ::Form::Page |
||||
def initialize(id, hsh, subsection) |
||||
super |
||||
@id = "buyer_2_living_in" |
||||
@depends_on = [{ "buyer_two_will_live_in_property?" => true }] |
||||
end |
||||
|
||||
def questions |
||||
@questions = [Form::Sales::Questions::Buyer2LivingIn.new(nil, nil, self)] |
||||
end |
||||
end |
||||
@ -0,0 +1,11 @@
|
||||
class Form::Sales::Pages::Buyer2Nationality < ::Form::Page |
||||
def initialize(id, hsh, subsection) |
||||
super |
||||
@id = "buyer_2_nationality" |
||||
@depends_on = [{ "joint_purchase?" => true }] |
||||
end |
||||
|
||||
def questions |
||||
@questions ||= [Form::Sales::Questions::Buyer2Nationality.new(nil, nil, self)] |
||||
end |
||||
end |
||||
@ -0,0 +1,11 @@
|
||||
class Form::Sales::Pages::Buyer2PreviousHousingSituation < ::Form::Page |
||||
def initialize(id, hsh, subsection) |
||||
super |
||||
@id = "buyer_2_previous_housing_situation" |
||||
@depends_on = [{ "buyer_two_not_already_living_in_property?" => true }] |
||||
end |
||||
|
||||
def questions |
||||
@questions = [Form::Sales::Questions::PreviousTenureBuyer2.new(nil, nil, self)] |
||||
end |
||||
end |
||||
@ -0,0 +1,17 @@
|
||||
class Form::Sales::Questions::Buyer2LivingIn < ::Form::Question |
||||
def initialize(id, hsh, page) |
||||
super |
||||
@id = "buy2living" |
||||
@check_answer_label = "Buyer 2 living at the same address" |
||||
@header = "At the time of purchase, was buyer 2 living at the same address as buyer 1?" |
||||
@type = "radio" |
||||
@hint_text = "" |
||||
@answer_options = ANSWER_OPTIONS |
||||
end |
||||
|
||||
ANSWER_OPTIONS = { |
||||
"1" => { "value" => "Yes" }, |
||||
"2" => { "value" => "No" }, |
||||
"3" => { "value" => "Don't know" }, |
||||
}.freeze |
||||
end |
||||
@ -0,0 +1,26 @@
|
||||
class Form::Sales::Questions::Buyer2Nationality < ::Form::Question |
||||
def initialize(id, hsh, page) |
||||
super |
||||
@id = "nationalbuy2" |
||||
@check_answer_label = "Buyer 2’s nationality" |
||||
@header = "What is buyer 2’s nationality?" |
||||
@type = "radio" |
||||
@answer_options = ANSWER_OPTIONS |
||||
@check_answers_card_number = 2 |
||||
@question_number = 32 |
||||
@inferred_check_answers_value = [{ |
||||
"condition" => { |
||||
"national" => 13, |
||||
}, |
||||
"value" => "Prefers not to say", |
||||
}] |
||||
end |
||||
|
||||
ANSWER_OPTIONS = { |
||||
"18" => { "value" => "United Kingdom" }, |
||||
"17" => { "value" => "Republic of Ireland" }, |
||||
"19" => { "value" => "European Economic Area (EEA), excluding ROI" }, |
||||
"12" => { "value" => "Other" }, |
||||
"13" => { "value" => "Buyer prefers not to say" }, |
||||
}.freeze |
||||
end |
||||
@ -1,11 +0,0 @@
|
||||
class Form::Sales::Questions::OtherNationality1 < ::Form::Question |
||||
def initialize(id, hsh, page) |
||||
super |
||||
@id = "othernational" |
||||
@check_answer_label = "Buyer 1’s nationality" |
||||
@header = "Nationality" |
||||
@type = "text" |
||||
@check_answers_card_number = 1 |
||||
@question_number = 24 |
||||
end |
||||
end |
||||
@ -0,0 +1,23 @@
|
||||
class Form::Sales::Questions::PreviousTenureBuyer2 < ::Form::Question |
||||
def initialize(id, hsh, page) |
||||
super |
||||
@id = "prevtenbuy2" |
||||
@check_answer_label = "Buyer 2’s previous tenure" |
||||
@header = "What was buyer 2’s previous tenure?" |
||||
@type = "radio" |
||||
@hint_text = "" |
||||
@answer_options = ANSWER_OPTIONS |
||||
end |
||||
|
||||
ANSWER_OPTIONS = { |
||||
"1" => { "value" => "Local authority tenant" }, |
||||
"2" => { "value" => "Private registered provider or housing association tenant" }, |
||||
"3" => { "value" => "Private tenant" }, |
||||
"5" => { "value" => "Owner occupier" }, |
||||
"4" => { "value" => "Tied home or renting with job" }, |
||||
"6" => { "value" => "Living with family or friends" }, |
||||
"7" => { "value" => "Temporary accommodation" }, |
||||
"9" => { "value" => "Other" }, |
||||
"0" => { "value" => "Don't know" }, |
||||
}.freeze |
||||
end |
||||
@ -0,0 +1,81 @@
|
||||
require "csv" |
||||
|
||||
class BulkUpload::Lettings::Year2023::CsvParser |
||||
MIN_COLUMNS = 141 |
||||
MAX_COLUMNS = 143 |
||||
|
||||
attr_reader :path |
||||
|
||||
def initialize(path:) |
||||
@path = path |
||||
end |
||||
|
||||
def row_offset |
||||
if with_headers? |
||||
rows.find_index { |row| row[0].match(/field number/i) } + 1 |
||||
else |
||||
0 |
||||
end |
||||
end |
||||
|
||||
def col_offset |
||||
with_headers? ? 1 : 0 |
||||
end |
||||
|
||||
def cols |
||||
@cols ||= ("A".."EL").to_a |
||||
end |
||||
|
||||
def row_parsers |
||||
@row_parsers ||= body_rows.map do |row| |
||||
stripped_row = row[col_offset..] |
||||
hash = Hash[field_numbers.zip(stripped_row)] |
||||
|
||||
BulkUpload::Lettings::Year2023::RowParser.new(hash) |
||||
end |
||||
end |
||||
|
||||
def body_rows |
||||
rows[row_offset..] |
||||
end |
||||
|
||||
def rows |
||||
@rows ||= CSV.parse(normalised_string, row_sep:) |
||||
end |
||||
|
||||
def column_for_field(field) |
||||
cols[field_numbers.find_index(field) + col_offset] |
||||
end |
||||
|
||||
private |
||||
|
||||
def default_field_numbers |
||||
[5, nil, nil, 15, 16, nil, 13, 40, 41, 42, 43, 46, 52, 56, 60, 64, 68, 72, 76, 47, 53, 57, 61, 65, 69, 73, 77, 51, 55, 59, 63, 67, 71, 75, 50, 54, 58, 62, 66, 70, 74, 78, 48, 49, 79, 81, 82, 123, 124, 122, 120, 102, 103, nil, 83, 84, 85, 86, 87, 88, 104, 109, 107, 108, 106, 100, 101, 105, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 126, 128, 129, 130, 131, 132, 127, 125, 133, 134, 33, 34, 35, 36, 37, 38, nil, 7, 8, 9, 28, 14, 32, 29, 30, 31, 26, 27, 25, 23, 24, nil, 1, 3, 2, 80, nil, 121, 44, 89, 98, 92, 95, 90, 91, 93, 94, 97, 96, 99, 10, 11, 12, 45, 39, 6, 4, 17, 18, 19, 20, 21, 22].map { |h| h.present? ? "field_#{h}" : "field_blank" } |
||||
end |
||||
|
||||
def field_numbers |
||||
@field_numbers ||= if with_headers? |
||||
rows[row_offset - 1][col_offset..].map { |h| h.present? ? "field_#{h}" : "field_blank" } |
||||
else |
||||
default_field_numbers |
||||
end |
||||
end |
||||
|
||||
def with_headers? |
||||
rows.map { |r| r[0] }.any? { |cell| cell&.match?(/field number/i) } |
||||
end |
||||
|
||||
def row_sep |
||||
"\n" |
||||
end |
||||
|
||||
def normalised_string |
||||
return @normalised_string if @normalised_string |
||||
|
||||
@normalised_string = File.read(path, encoding: "bom|utf-8") |
||||
@normalised_string.gsub!("\r\n", "\n") |
||||
@normalised_string.scrub!("") |
||||
|
||||
@normalised_string |
||||
end |
||||
end |
||||
File diff suppressed because it is too large
Load Diff
@ -1,176 +0,0 @@
|
||||
class BulkUpload::Sales::RowParser |
||||
include ActiveModel::Model |
||||
include ActiveModel::Attributes |
||||
|
||||
attribute :field_1, :string |
||||
attribute :field_2, :integer |
||||
attribute :field_3, :integer |
||||
attribute :field_4, :integer |
||||
attribute :field_5 |
||||
attribute :field_6, :integer |
||||
attribute :field_7, :integer |
||||
attribute :field_8, :integer |
||||
attribute :field_9, :integer |
||||
attribute :field_10, :integer |
||||
attribute :field_11, :integer |
||||
attribute :field_12, :integer |
||||
attribute :field_13, :string |
||||
attribute :field_14, :string |
||||
attribute :field_15, :string |
||||
attribute :field_16, :string |
||||
attribute :field_17, :string |
||||
attribute :field_18, :string |
||||
attribute :field_19, :string |
||||
attribute :field_20, :integer |
||||
attribute :field_21, :integer |
||||
attribute :field_22, :integer |
||||
attribute :field_23, :integer |
||||
attribute :field_24, :integer |
||||
attribute :field_25, :integer |
||||
attribute :field_26, :integer |
||||
attribute :field_27, :integer |
||||
attribute :field_28, :integer |
||||
attribute :field_29, :integer |
||||
attribute :field_30, :integer |
||||
attribute :field_31, :integer |
||||
attribute :field_32, :integer |
||||
attribute :field_33, :integer |
||||
attribute :field_34, :integer |
||||
attribute :field_35, :integer |
||||
attribute :field_36, :integer |
||||
attribute :field_37, :integer |
||||
attribute :field_38 |
||||
attribute :field_39, :integer |
||||
attribute :field_40, :string |
||||
attribute :field_41, :string |
||||
attribute :field_42, :string |
||||
attribute :field_43, :integer |
||||
attribute :field_44, :integer |
||||
attribute :field_45, :integer |
||||
attribute :field_46, :integer |
||||
attribute :field_47, :integer |
||||
attribute :field_48, :integer |
||||
attribute :field_49, :integer |
||||
attribute :field_50, :integer |
||||
attribute :field_51, :integer |
||||
attribute :field_52, :integer |
||||
attribute :field_53, :string |
||||
attribute :field_54, :string |
||||
attribute :field_55, :string |
||||
attribute :field_56, :integer |
||||
attribute :field_57, :integer |
||||
attribute :field_58, :integer |
||||
attribute :field_59, :integer |
||||
attribute :field_60, :integer |
||||
attribute :field_61, :integer |
||||
attribute :field_62, :integer |
||||
attribute :field_63, :integer |
||||
attribute :field_64, :integer |
||||
attribute :field_65, :integer |
||||
attribute :field_66, :integer |
||||
attribute :field_67, :integer |
||||
attribute :field_68, :integer |
||||
attribute :field_69, :integer |
||||
attribute :field_70, :integer |
||||
attribute :field_71, :integer |
||||
attribute :field_72, :integer |
||||
attribute :field_73, :integer |
||||
attribute :field_74, :decimal |
||||
attribute :field_75, :decimal |
||||
attribute :field_76, :integer |
||||
attribute :field_77, :integer |
||||
attribute :field_78, :integer |
||||
attribute :field_79, :integer |
||||
attribute :field_80, :integer |
||||
attribute :field_81, :integer |
||||
attribute :field_82, :integer |
||||
attribute :field_83, :integer |
||||
attribute :field_84, :integer |
||||
attribute :field_85, :string |
||||
attribute :field_86 |
||||
attribute :field_87, :integer |
||||
attribute :field_88, :integer |
||||
attribute :field_89, :integer |
||||
attribute :field_90, :integer |
||||
attribute :field_91, :integer |
||||
attribute :field_92, :integer |
||||
attribute :field_93, :string |
||||
attribute :field_94 |
||||
attribute :field_95, :integer |
||||
attribute :field_96 |
||||
attribute :field_97, :integer |
||||
attribute :field_98, :integer |
||||
attribute :field_99, :string |
||||
attribute :field_100, :integer |
||||
attribute :field_101, :string |
||||
attribute :field_102, :integer |
||||
attribute :field_103, :string |
||||
attribute :field_104, :integer |
||||
attribute :field_105, :integer |
||||
attribute :field_106, :integer |
||||
attribute :field_107, :integer |
||||
attribute :field_108, :integer |
||||
attribute :field_109, :integer |
||||
attribute :field_110, :integer |
||||
attribute :field_111, :integer |
||||
attribute :field_112, :integer |
||||
attribute :field_113, :integer |
||||
attribute :field_114, :integer |
||||
attribute :field_115, :integer |
||||
attribute :field_116, :integer |
||||
attribute :field_117, :integer |
||||
attribute :field_118, :integer |
||||
attribute :field_119, :integer |
||||
attribute :field_120, :integer |
||||
attribute :field_121, :integer |
||||
attribute :field_122, :integer |
||||
attribute :field_123, :integer |
||||
attribute :field_124, :integer |
||||
attribute :field_125, :integer |
||||
|
||||
# validates :field_1, presence: true, numericality: { in: (1..12) } |
||||
# validates :field_4, numericality: { in: (1..999), allow_blank: true } |
||||
# validates :field_4, presence: true, if: :field_4_presence_check |
||||
|
||||
validate :validate_possible_answers |
||||
|
||||
# delegate :valid?, to: :native_object |
||||
# delegate :errors, to: :native_object |
||||
|
||||
private |
||||
|
||||
def native_object |
||||
@native_object ||= SalesLog.new(attributes_for_log) |
||||
end |
||||
|
||||
def field_mapping |
||||
{ |
||||
field_117: :buy1livein, |
||||
} |
||||
end |
||||
|
||||
def validate_possible_answers |
||||
field_mapping.each do |field, attribute| |
||||
possible_answers = FormHandler.instance.current_sales_form.questions.find { |q| q.id == attribute.to_s }.answer_options.keys |
||||
|
||||
unless possible_answers.include?(public_send(field)) |
||||
errors.add(field, "Value supplied is not one of the permitted values") |
||||
end |
||||
end |
||||
end |
||||
|
||||
def attributes_for_log |
||||
hash = field_mapping.invert |
||||
attributes = {} |
||||
|
||||
hash.map do |k, v| |
||||
attributes[k] = public_send(v) |
||||
end |
||||
|
||||
attributes |
||||
end |
||||
|
||||
# def field_4_presence_check |
||||
# [1, 3, 5, 7, 9, 11].include?(field_1) |
||||
# end |
||||
end |
||||
@ -0,0 +1,308 @@
|
||||
class BulkUpload::Sales::Year2022::RowParser |
||||
include ActiveModel::Model |
||||
include ActiveModel::Attributes |
||||
|
||||
QUESTIONS = { |
||||
field_1: "What is the purchaser code?", |
||||
field_2: "What is the day of the sale completion date? - DD", |
||||
field_3: "What is the month of the sale completion date? - MM", |
||||
field_4: "What is the year of the sale completion date? - YY", |
||||
field_5: "This question has been removed", |
||||
field_6: "Was the buyer interviewed for any of the answers you will provide on this log?", |
||||
field_7: "Age of Buyer 1", |
||||
field_8: "Age of Person 2", |
||||
field_9: "Age of Person 3", |
||||
field_10: "Age of Person 4", |
||||
field_11: "Age of Person 5", |
||||
field_12: "Age of Person 6", |
||||
field_13: "Gender identity of Buyer 1", |
||||
field_14: "Gender identity of Person 2", |
||||
field_15: "Gender identity of Person 3", |
||||
field_16: "Gender identity of Person 4", |
||||
field_17: "Gender identity of Person 5", |
||||
field_18: "Gender identity of Person 6", |
||||
field_19: "Relationship to Buyer 1 for Person 2", |
||||
field_20: "Relationship to Buyer 1 for Person 3", |
||||
field_21: "Relationship to Buyer 1 for Person 4", |
||||
field_22: "Relationship to Buyer 1 for Person 5", |
||||
field_23: "Relationship to Buyer 1 for Person 6", |
||||
field_24: "Working situation of Buyer 1", |
||||
field_25: "Working situation of Person 2", |
||||
field_26: "Working situation of Person 3", |
||||
field_27: "Working situation of Person 4", |
||||
field_28: "Working situation of Person 5", |
||||
field_29: "Working situation of Person 6", |
||||
field_30: "What is buyer 1's ethnic group?", |
||||
field_31: "What is buyer 1's nationality?", |
||||
field_32: "What is buyer 1's gross annual income?", |
||||
field_33: "What is buyer 2's gross annual income?", |
||||
field_34: "Was buyer 1's income used for a mortgage application?", |
||||
field_35: "Was buyer 2's income used for a mortgage application?", |
||||
field_36: "What is the total amount the buyers had in savings before they paid any deposit for the property?", |
||||
field_37: "Have any of the purchasers previously owned a property?", |
||||
field_38: "This question has been removed", |
||||
field_39: "What was buyer 1's previous tenure?", |
||||
field_40: "What is the local authority of buyer 1's last settled home?", |
||||
field_41: "Part 1 of postcode of buyer 1's last settled home", |
||||
field_42: "Part 2 of postcode of buyer 1's last settled home", |
||||
field_43: "Do you know the postcode of buyer 1's last settled home?", |
||||
field_44: "Was the buyer registered with their PRP (HA)?", |
||||
field_45: "Was the buyer registered with the local authority?", |
||||
field_46: "Was the buyer registered with a Help to Buy agent?", |
||||
field_47: "Was the buyer registered with another PRP (HA)?", |
||||
field_48: "Does anyone in the household consider themselves to have a disability?", |
||||
field_49: "Does anyone in the household use a wheelchair?", |
||||
field_50: "How many bedrooms does the property have?", |
||||
field_51: "What type of unit is the property?", |
||||
field_52: "Which type of bulding is the property?", |
||||
field_53: "What is the local authority of the property?", |
||||
field_54: "Part 1 of postcode of property", |
||||
field_55: "Part 2 of postcode of property", |
||||
field_56: "Is the property built or adapted to wheelchair user standards?", |
||||
field_57: "What is the type of shared ownership sale?", |
||||
field_58: "Is this a resale?", |
||||
field_59: "What is the day of the practical completion or handover date?", |
||||
field_60: "What is the month of the practical completion or handover date?", |
||||
field_61: "What is the day of the exchange of contracts date?", |
||||
field_62: "What is the day of the practical completion or handover date?", |
||||
field_63: "What is the month of the practical completion or handover date?", |
||||
field_64: "What is the year of the practical completion or handover date?", |
||||
field_65: "Was the household re-housed under a local authority nominations agreement?", |
||||
field_66: "How many bedrooms did the buyer's previous property have?", |
||||
field_67: "What was the type of the buyer's previous property?", |
||||
field_68: "What was the full purchase price?", |
||||
field_69: "What was the initial percentage equity stake purchased?", |
||||
field_70: "What is the mortgage amount?", |
||||
field_71: "Does this include any extra borrowing?", |
||||
field_72: "How much was the cash deposit paid on the property?", |
||||
field_73: "How much cash discount was given through Social Homebuy?", |
||||
field_74: "What is the basic monthly rent?", |
||||
field_75: "What are the total monthly leasehold charges for the property?", |
||||
field_76: "What is the type of discounted ownership sale?", |
||||
field_77: "What was the full purchase price?", |
||||
field_78: "What was the amount of any loan, grant, discount or subsidy given?", |
||||
field_79: "What was the percentage discount?", |
||||
field_80: "What is the mortgage amount?", |
||||
field_81: "Does this include any extra borrowing?", |
||||
field_82: "How much was the cash deposit paid on the property?", |
||||
field_83: "What are the total monthly leasehold charges for the property?", |
||||
field_84: "What is the type of outright sale?", |
||||
field_85: "If 'other', what is the 'other' type?", |
||||
field_86: "This question has been removed", |
||||
field_87: "What is the full purchase price?", |
||||
field_88: "What is the mortgage amount?", |
||||
field_89: "Does this include any extra borrowing?", |
||||
field_90: "How much was the cash deposit paid on the property?", |
||||
field_91: "What are the total monthly leasehold charges for the property?", |
||||
field_92: "Which organisation owned this property before the sale?", |
||||
field_93: "Username", |
||||
field_94: "This question has been removed", |
||||
field_95: "Has the buyer ever served in the UK Armed Forces and for how long?", |
||||
field_96: "This question has been removed", |
||||
field_97: "Are any of the buyers a spouse or civil partner of a UK Armed Forces regular who died in service within the last 2 years?", |
||||
field_98: "What is the name of the mortgage lender? - Shared ownership", |
||||
field_99: "If 'other', what is the name of the mortgage lender?", |
||||
field_100: "What is the name of the mortgage lender? - Discounted ownership", |
||||
field_101: "If 'other', what is the name of the mortgage lender?", |
||||
field_102: "What is the name of the mortgage lender? - Outright sale", |
||||
field_103: "If 'other', what is the name of the mortgage lender?", |
||||
field_104: "Were the buyers receiving any of these housing-related benefits immediately before buying this property?", |
||||
field_105: "What is the length of the mortgage in years? - Shared ownership", |
||||
field_106: "What is the length of the mortgage in years? - Discounted ownership", |
||||
field_107: "What is the length of the mortgage in years? - Outright sale", |
||||
field_108: "How long have the buyers been living in the property before the purchase? - Discounted ownership", |
||||
field_109: "Are there more than two joint purchasers of this property?", |
||||
field_110: "How long have the buyers been living in the property before the purchase? - Shared ownership", |
||||
field_111: "Is this a staircasing transaction?", |
||||
field_112: "Data Protection question", |
||||
field_113: "Was this purchase made through an ownership scheme?", |
||||
field_114: "Is the buyer a company?", |
||||
field_115: "Will the buyers live in the property?", |
||||
field_116: "Is this a joint purchase?", |
||||
field_117: "Will buyer 1 live in the property?", |
||||
field_118: "Will buyer 2 live in the property?", |
||||
field_119: "Besides the buyers, how many people will live in the property?", |
||||
field_120: "What percentage of the property has been bought in this staircasing transaction?", |
||||
field_121: "What percentage of the property does the buyer now own in total?", |
||||
field_122: "What was the rent type of the buyer's previous property?", |
||||
field_123: "Was a mortgage used for the purchase of this property? - Shared ownership", |
||||
field_124: "Was a mortgage used for the purchase of this property? - Discounted ownership", |
||||
field_125: "Was a mortgage used for the purchase of this property? - Outright sale", |
||||
}.freeze |
||||
|
||||
attribute :field_1, :string |
||||
attribute :field_2, :integer |
||||
attribute :field_3, :integer |
||||
attribute :field_4, :integer |
||||
attribute :field_5 |
||||
attribute :field_6, :integer |
||||
attribute :field_7, :integer |
||||
attribute :field_8, :integer |
||||
attribute :field_9, :integer |
||||
attribute :field_10, :integer |
||||
attribute :field_11, :integer |
||||
attribute :field_12, :integer |
||||
attribute :field_13, :string |
||||
attribute :field_14, :string |
||||
attribute :field_15, :string |
||||
attribute :field_16, :string |
||||
attribute :field_17, :string |
||||
attribute :field_18, :string |
||||
attribute :field_19, :string |
||||
attribute :field_20, :integer |
||||
attribute :field_21, :integer |
||||
attribute :field_22, :integer |
||||
attribute :field_23, :integer |
||||
attribute :field_24, :integer |
||||
attribute :field_25, :integer |
||||
attribute :field_26, :integer |
||||
attribute :field_27, :integer |
||||
attribute :field_28, :integer |
||||
attribute :field_29, :integer |
||||
attribute :field_30, :integer |
||||
attribute :field_31, :integer |
||||
attribute :field_32, :integer |
||||
attribute :field_33, :integer |
||||
attribute :field_34, :integer |
||||
attribute :field_35, :integer |
||||
attribute :field_36, :integer |
||||
attribute :field_37, :integer |
||||
attribute :field_38 |
||||
attribute :field_39, :integer |
||||
attribute :field_40, :string |
||||
attribute :field_41, :string |
||||
attribute :field_42, :string |
||||
attribute :field_43, :integer |
||||
attribute :field_44, :integer |
||||
attribute :field_45, :integer |
||||
attribute :field_46, :integer |
||||
attribute :field_47, :integer |
||||
attribute :field_48, :integer |
||||
attribute :field_49, :integer |
||||
attribute :field_50, :integer |
||||
attribute :field_51, :integer |
||||
attribute :field_52, :integer |
||||
attribute :field_53, :string |
||||
attribute :field_54, :string |
||||
attribute :field_55, :string |
||||
attribute :field_56, :integer |
||||
attribute :field_57, :integer |
||||
attribute :field_58, :integer |
||||
attribute :field_59, :integer |
||||
attribute :field_60, :integer |
||||
attribute :field_61, :integer |
||||
attribute :field_62, :integer |
||||
attribute :field_63, :integer |
||||
attribute :field_64, :integer |
||||
attribute :field_65, :integer |
||||
attribute :field_66, :integer |
||||
attribute :field_67, :integer |
||||
attribute :field_68, :integer |
||||
attribute :field_69, :integer |
||||
attribute :field_70, :integer |
||||
attribute :field_71, :integer |
||||
attribute :field_72, :integer |
||||
attribute :field_73, :integer |
||||
attribute :field_74, :decimal |
||||
attribute :field_75, :decimal |
||||
attribute :field_76, :integer |
||||
attribute :field_77, :integer |
||||
attribute :field_78, :integer |
||||
attribute :field_79, :integer |
||||
attribute :field_80, :integer |
||||
attribute :field_81, :integer |
||||
attribute :field_82, :integer |
||||
attribute :field_83, :integer |
||||
attribute :field_84, :integer |
||||
attribute :field_85, :string |
||||
attribute :field_86 |
||||
attribute :field_87, :integer |
||||
attribute :field_88, :integer |
||||
attribute :field_89, :integer |
||||
attribute :field_90, :integer |
||||
attribute :field_91, :integer |
||||
attribute :field_92, :integer |
||||
attribute :field_93, :string |
||||
attribute :field_94 |
||||
attribute :field_95, :integer |
||||
attribute :field_96 |
||||
attribute :field_97, :integer |
||||
attribute :field_98, :integer |
||||
attribute :field_99, :string |
||||
attribute :field_100, :integer |
||||
attribute :field_101, :string |
||||
attribute :field_102, :integer |
||||
attribute :field_103, :string |
||||
attribute :field_104, :integer |
||||
attribute :field_105, :integer |
||||
attribute :field_106, :integer |
||||
attribute :field_107, :integer |
||||
attribute :field_108, :integer |
||||
attribute :field_109, :integer |
||||
attribute :field_110, :integer |
||||
attribute :field_111, :integer |
||||
attribute :field_112, :integer |
||||
attribute :field_113, :integer |
||||
attribute :field_114, :integer |
||||
attribute :field_115, :integer |
||||
attribute :field_116, :integer |
||||
attribute :field_117, :integer |
||||
attribute :field_118, :integer |
||||
attribute :field_119, :integer |
||||
attribute :field_120, :integer |
||||
attribute :field_121, :integer |
||||
attribute :field_122, :integer |
||||
attribute :field_123, :integer |
||||
attribute :field_124, :integer |
||||
attribute :field_125, :integer |
||||
|
||||
# validates :field_1, presence: true, numericality: { in: (1..12) } |
||||
# validates :field_4, numericality: { in: (1..999), allow_blank: true } |
||||
# validates :field_4, presence: true, if: :field_4_presence_check |
||||
|
||||
validate :validate_possible_answers |
||||
|
||||
# delegate :valid?, to: :native_object |
||||
# delegate :errors, to: :native_object |
||||
|
||||
def self.question_for_field(field) |
||||
QUESTIONS[field] |
||||
end |
||||
|
||||
private |
||||
|
||||
def native_object |
||||
@native_object ||= SalesLog.new(attributes_for_log) |
||||
end |
||||
|
||||
def field_mapping |
||||
{ |
||||
field_117: :buy1livein, |
||||
} |
||||
end |
||||
|
||||
def validate_possible_answers |
||||
field_mapping.each do |field, attribute| |
||||
possible_answers = FormHandler.instance.current_sales_form.questions.find { |q| q.id == attribute.to_s }.answer_options.keys |
||||
|
||||
unless possible_answers.include?(public_send(field)) |
||||
errors.add(field, "Value supplied is not one of the permitted values") |
||||
end |
||||
end |
||||
end |
||||
|
||||
def attributes_for_log |
||||
hash = field_mapping.invert |
||||
attributes = {} |
||||
|
||||
hash.map do |k, v| |
||||
attributes[k] = public_send(v) |
||||
end |
||||
|
||||
attributes |
||||
end |
||||
|
||||
# def field_4_presence_check |
||||
# [1, 3, 5, 7, 9, 11].include?(field_1) |
||||
# end |
||||
end |
||||
|
@ -0,0 +1,8 @@
|
||||
class AddColumnsToSalesLog < ActiveRecord::Migration[7.0] |
||||
def change |
||||
change_table :sales_logs, bulk: true do |t| |
||||
t.column :buy2living, :integer |
||||
t.column :prevtenbuy2, :integer |
||||
end |
||||
end |
||||
end |
||||
@ -0,0 +1,5 @@
|
||||
class RemoveOthernationalFromSalesLogs < ActiveRecord::Migration[7.0] |
||||
def change |
||||
remove_column :sales_logs, :othernational, :string |
||||
end |
||||
end |
||||
@ -0,0 +1,5 @@
|
||||
class AddNationalbuy2ToSalesLogs < ActiveRecord::Migration[7.0] |
||||
def change |
||||
add_column :sales_logs, :nationalbuy2, :integer |
||||
end |
||||
end |
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -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,48 @@
|
||||
require "rails_helper" |
||||
|
||||
RSpec.describe Form::Lettings::Questions::Nationality, 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("national") |
||||
end |
||||
|
||||
it "has the correct header" do |
||||
expect(question.header).to eq("What is the nationality of the lead tenant?") |
||||
end |
||||
|
||||
it "has the correct check_answer_label" do |
||||
expect(question.check_answer_label).to eq("Lead tenant’s nationality") |
||||
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("The lead tenant is the person in the household who does the most paid work. If several people do the same paid work, the lead tenant is whoever is the oldest.") |
||||
end |
||||
|
||||
it "has the correct answer_options" do |
||||
expect(question.answer_options).to eq({ |
||||
"18" => { "value" => "United Kingdom" }, |
||||
"17" => { "value" => "Republic of Ireland" }, |
||||
"19" => { "value" => "European Economic Area (EEA) country, excluding Ireland" }, |
||||
"20" => { "value" => "Afghanistan" }, |
||||
"21" => { "value" => "Ukraine" }, |
||||
"12" => { "value" => "Other" }, |
||||
"divider" => true, |
||||
"13" => { "value" => "Tenant prefers not to say" }, |
||||
}) |
||||
end |
||||
|
||||
it "is not marked as derived" do |
||||
expect(question.derived?).to be false |
||||
end |
||||
end |
||||
@ -0,0 +1,158 @@
|
||||
require "rails_helper" |
||||
|
||||
RSpec.describe Form::Lettings::Questions::Reason, 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("reason") |
||||
end |
||||
|
||||
it "has the correct header" do |
||||
expect(question.header).to eq("What is the tenant’s main reason for the household leaving their last settled home?") |
||||
end |
||||
|
||||
it "has the correct check_answer_label" do |
||||
expect(question.check_answer_label).to eq("Reason for leaving last settled home") |
||||
end |
||||
|
||||
it "has the correct type" do |
||||
expect(question.type).to eq("radio") |
||||
end |
||||
|
||||
it "has the correct check_answers_card_number" do |
||||
expect(question.check_answers_card_number).to eq(0) |
||||
end |
||||
|
||||
it "has the correct hint" do |
||||
expect(question.hint_text).to eq("The tenant’s ‘last settled home’ is their last long-standing home. For tenants who were in temporary accommodation or sleeping rough, their last settled home is where they were living previously.") |
||||
end |
||||
|
||||
it "has the correct conditional_for" do |
||||
expect(question.conditional_for).to eq({ "reasonother" => [20] }) |
||||
end |
||||
|
||||
it "is not marked as derived" do |
||||
expect(question).not_to be_derived |
||||
end |
||||
|
||||
it "has the correct answer_options" do |
||||
expect(question.answer_options).to eq({ |
||||
"40" => { |
||||
"value" => "End of assured shorthold tenancy (no fault)", |
||||
}, |
||||
"41" => { |
||||
"value" => "End of assured shorthold tenancy (eviction or tenant at fault)", |
||||
}, |
||||
"42" => { |
||||
"value" => "End of fixed term tenancy (no fault)", |
||||
}, |
||||
"43" => { |
||||
"value" => "End of fixed term tenancy (eviction or tenant at fault)", |
||||
}, |
||||
"1" => { |
||||
"value" => "Permanently decanted from another property owned by this landlord", |
||||
}, |
||||
"46" => { |
||||
"value" => "Discharged from long-stay hospital or similar institution", |
||||
}, |
||||
"45" => { |
||||
"value" => "Discharged from prison", |
||||
}, |
||||
"2" => { |
||||
"value" => "Left home country as a refugee", |
||||
}, |
||||
"4" => { |
||||
"value" => "Loss of tied accommodation", |
||||
}, |
||||
"9" => { |
||||
"value" => "Asked to leave by family or friends", |
||||
}, |
||||
"44" => { |
||||
"value" => "Death of household member in last settled accommodation", |
||||
}, |
||||
"8" => { |
||||
"value" => "Relationship breakdown (non-violent) with partner", |
||||
}, |
||||
"16" => { |
||||
"value" => "To move nearer to family, friends or school", |
||||
}, |
||||
"17" => { |
||||
"value" => "To move nearer to work", |
||||
}, |
||||
"48" => { |
||||
"value" => "Domestic abuse - previously joint tenancy with partner", |
||||
}, |
||||
"49" => { |
||||
"value" => "Domestic abuse - other", |
||||
}, |
||||
"31" => { |
||||
"value" => "Hate crime", |
||||
}, |
||||
"10" => { |
||||
"value" => "Racial harassment", |
||||
}, |
||||
"11" => { |
||||
"value" => "Other problems with neighbours", |
||||
}, |
||||
"35" => { |
||||
"value" => "Couldn’t afford fees attached to renewing the tenancy", |
||||
}, |
||||
"36" => { |
||||
"value" => "Couldn’t afford increase in rent", |
||||
}, |
||||
"38" => { |
||||
"value" => "Couldn’t afford rent or mortgage (employment)", |
||||
}, |
||||
"37" => { |
||||
"value" => "Couldn’t afford rent or mortgage (welfare reforms)", |
||||
}, |
||||
"39" => { |
||||
"value" => "Couldn’t afford rent or mortgage (other)", |
||||
}, |
||||
"34" => { |
||||
"value" => "Repossession", |
||||
}, |
||||
"12" => { |
||||
"value" => "Property unsuitable because of overcrowding", |
||||
}, |
||||
"13" => { |
||||
"value" => "Property unsuitable because of ill health or disability", |
||||
}, |
||||
"14" => { |
||||
"value" => "Property unsuitable because of poor condition", |
||||
}, |
||||
"18" => { |
||||
"value" => "To move to accommodation with support", |
||||
}, |
||||
"19" => { |
||||
"value" => "To move to independent accommodation", |
||||
}, |
||||
"30" => { |
||||
"value" => "Under occupation (no incentive)", |
||||
}, |
||||
"29" => { |
||||
"value" => "Under occupation (offered incentive to downsize)", |
||||
}, |
||||
"20" => { |
||||
"value" => "Other", |
||||
}, |
||||
"47" => { |
||||
"value" => "Tenant prefers not to say", |
||||
}, |
||||
"divider" => { |
||||
"value" => true, |
||||
}, |
||||
"28" => { |
||||
"value" => "Don’t know", |
||||
}, |
||||
}) |
||||
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 |
||||
@ -0,0 +1,31 @@
|
||||
require "rails_helper" |
||||
|
||||
RSpec.describe Form::Sales::Pages::Buyer2LivingIn, 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[buy2living]) |
||||
end |
||||
|
||||
it "has the correct id" do |
||||
expect(page.id).to eq("buyer_2_living_in") |
||||
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 correct depends_on" do |
||||
expect(page.depends_on).to eq([{ "buyer_two_will_live_in_property?" => true }]) |
||||
end |
||||
end |
||||
@ -0,0 +1,31 @@
|
||||
require "rails_helper" |
||||
|
||||
RSpec.describe Form::Sales::Pages::Buyer2Nationality, 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 be subsection |
||||
end |
||||
|
||||
it "has correct questions" do |
||||
expect(page.questions.map(&:id)).to eq %w[nationalbuy2] |
||||
end |
||||
|
||||
it "has the correct id" do |
||||
expect(page.id).to eq "buyer_2_nationality" |
||||
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 correct depends_on" do |
||||
expect(page.depends_on).to eq [{ "joint_purchase?" => true }] |
||||
end |
||||
end |
||||
@ -0,0 +1,31 @@
|
||||
require "rails_helper" |
||||
|
||||
RSpec.describe Form::Sales::Pages::Buyer2PreviousHousingSituation, 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[prevtenbuy2]) |
||||
end |
||||
|
||||
it "has the correct id" do |
||||
expect(page.id).to eq("buyer_2_previous_housing_situation") |
||||
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 correct depends_on" do |
||||
expect(page.depends_on).to eq([{ "buyer_two_not_already_living_in_property?" => true }]) |
||||
end |
||||
end |
||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in new issue