diff --git a/app/models/case_log.rb b/app/models/case_log.rb
index 59dc8d3d3..3f1afb39c 100644
--- a/app/models/case_log.rb
+++ b/app/models/case_log.rb
@@ -122,19 +122,23 @@ class CaseLog < ApplicationRecord
end
def net_income_refused?
+ # 2: Tenant prefers not to say
net_income_known == 2
end
def net_income_is_weekly?
- !!(incfreq && incfreq.zero?)
+ # 1: Weekly
+ !!(incfreq && incfreq == 1)
end
def net_income_is_monthly?
- incfreq == 1
+ # 2: Monthly
+ incfreq == 2
end
def net_income_is_yearly?
- incfreq == 2
+ # 3: Yearly
+ incfreq == 3
end
def net_income_soft_validation_triggered?
@@ -142,138 +146,181 @@ class CaseLog < ApplicationRecord
end
def given_reasonable_preference?
+ # 1: Yes
reasonpref == 1
end
def is_renewal?
+ # 1: Yes
renewal == 1
end
def is_general_needs?
+ # 1: General Needs
needstype == 1
end
def is_supported_housing?
- !!(needstype && needstype.zero?)
+ # 0: Supported Housing
+ !!(needstype&.zero?)
end
def has_hbrentshortfall?
- !!(hbrentshortfall && hbrentshortfall.zero?)
+ # 0: Yes
+ !!(hbrentshortfall&.zero?)
end
def postcode_known?
+ # 1: Yes
postcode_known == 1
end
def previous_postcode_known?
+ # 1: Yes
previous_postcode_known == 1
end
def la_known?
+ # 1: Yes
la_known == 1
end
def previous_la_known?
+ # 1: Yes
previous_la_known == 1
end
def is_secure_tenancy?
- tenancy == 3
+ # 1: Secure (including flexible)
+ tenancy == 1
end
def is_assured_shorthold_tenancy?
- tenancy == 1
+ # 4: Assured Shorthold
+ tenancy == 4
end
def is_internal_transfer?
+ # 1: Internal Transfer
referral == 1
end
def is_relet_to_temp_tenant?
- rsnvac == 2
+ # 9: Re-let to tenant who occupied same property as temporary accommodation
+ rsnvac == 9
end
def is_bedsit?
- unittype_gn == 1
+ # 2: Bedsit
+ unittype_gn == 2
end
def is_shared_housing?
- [4, 5, 6].include?(unittype_gn)
+ # 4: Shared flat or maisonette
+ # 9: Shared house
+ # 10: Shared bungalow
+ [4, 9, 10].include?(unittype_gn)
end
def has_first_let_vacancy_reason?
+ # 15: First let of new-build property
+ # 16: First let of conversion, rehabilitation or acquired property
+ # 17: First let of leased property
[15, 16, 17].include?(rsnvac)
end
def previous_tenancy_was_temporary?
- ![4, 5, 16, 21, 22].include?(prevten)
+ # 4: Tied housing or renting with job
+ # 6: Supported housing
+ # 8: Sheltered accomodation
+ # 24: Housed by National Asylum Support Service (prev Home Office)
+ # 25: Other
+ ![4, 6, 8, 24, 25].include?(prevten)
end
def armed_forces_regular?
- !!(armedforces && armedforces.zero?)
+ # 1: Yes – the person is a current or former regular
+ !!(armedforces && armedforces == 1)
end
def armed_forces_no?
- armedforces == 3
+ # 2: No
+ armedforces == 2
end
def armed_forces_refused?
- armedforces == 4
+ # 3: Person prefers not to say / Refused
+ armedforces == 3
end
def has_pregnancy?
- !!(preg_occ && preg_occ.zero?)
+ # 1: Yes
+ !!(preg_occ && preg_occ == 1)
end
def pregnancy_refused?
- preg_occ == 2
+ # 3: Tenant prefers not to say / Refused
+ preg_occ == 3
end
def is_assessed_homeless?
+ # 11: Assessed as homeless (or threatened with homelessness within 56 days) by a local authority and owed a homelessness duty
homeless == 11
end
def is_other_homeless?
+ # 7: Other homeless – not found statutorily homeless but considered homeless by landlord
homeless == 7
end
def is_not_homeless?
+ # 1: No
homeless == 1
end
def is_london_rent?
+ # 2: London Affordable Rent
+ # 4: London Living Rent
rent_type == 2 || rent_type == 4
end
def previous_tenancy_was_foster_care?
+ # 13: Children's home or foster care
prevten == 13
end
def previous_tenancy_was_refuge?
+ # 21: Refuge
prevten == 21
end
def is_reason_permanently_decanted?
+ # 1: Permanently decanted from another property owned by this landlord
reason == 1
end
def receives_housing_benefit_only?
+ # 1: Housing benefit
hb == 1
end
def receives_housing_benefit_and_universal_credit?
+ # 8: Housing benefit and Universal Credit (without housing element)
hb == 8
end
def receives_uc_with_housing_element_excl_housing_benefit?
+ # 6: Universal Credit with housing element (excluding housing benefit)
hb == 6
end
def receives_no_benefits?
+ # 9: None
hb == 9
end
def receives_universal_credit_but_no_housing_benefit?
+ # 7: Universal Credit (without housing element)
hb == 7
end
@@ -283,23 +330,31 @@ class CaseLog < ApplicationRecord
end
def benefits_unknown?
+ # 3: Don’t know
hb == 3
end
def this_landlord?
+ # 1: This landlord
landlord == 1
end
def other_landlord?
+ # 2: Another RP (HA/LA)
landlord == 2
end
def local_housing_referral?
+ # 3: PRP lettings only - Nominated by local housing authority
referral == 3
end
def is_prevten_la_general_needs?
- [30, 31].any?(prevten)
+ # 30: Fixed term Local Authority General Needs tenancy
+ # 31: Lifetime Local Authority General Needs tenancy
+ # 32: Fixed term Private Registered Provider General Needs tenancy
+ # 33: Lifetime Private Registered Provider General Needs tenancy
+ [30, 31, 32, 33].any?(prevten)
end
def self.to_csv
@@ -418,6 +473,7 @@ private
self.referral = 0
self.layear = 1
if is_general_needs?
+ # TODO: Check value since 30/31 are LA and 32/33 are PRP (fixed term VS lifetime)
self.prevten = 32 if managing_organisation.provider_type == "PRP"
self.prevten = 30 if managing_organisation.provider_type == "LA"
end
diff --git a/app/models/form/question.rb b/app/models/form/question.rb
index 8d1d43a7c..f0b4788e9 100644
--- a/app/models/form/question.rb
+++ b/app/models/form/question.rb
@@ -218,9 +218,9 @@ private
end
ANSWER_SUFFIX_LABELS = {
- 0 => " every week",
- 1 => " every month",
- 2 => " every year",
+ 1 => " every week",
+ 2 => " every month",
+ 3 => " every year",
}.freeze
RADIO_YES_VALUE = {
diff --git a/app/models/validations/tenancy_validations.rb b/app/models/validations/tenancy_validations.rb
index b6991f1c6..84af343c6 100644
--- a/app/models/validations/tenancy_validations.rb
+++ b/app/models/validations/tenancy_validations.rb
@@ -30,6 +30,6 @@ module Validations::TenancyValidations
end
def validate_other_tenancy_type(record)
- validate_other_field(record, 4, :tenancy, :tenancyother)
+ validate_other_field(record, 3, :tenancy, :tenancyother)
end
end
diff --git a/app/services/imports/case_logs_import_service.rb b/app/services/imports/case_logs_import_service.rb
index c8d99fbfc..bc11d0ef5 100644
--- a/app/services/imports/case_logs_import_service.rb
+++ b/app/services/imports/case_logs_import_service.rb
@@ -148,11 +148,9 @@ module Imports
attributes["la_known"] = 1 # Defaulting to Yes (Required)
attributes["created_at"] = Date.parse(field_value(xml_doc, "meta", "created-date"))
attributes["updated_at"] = Date.parse(field_value(xml_doc, "meta", "modified-date"))
- attributes
- # Pending validation with new form
- # case_log = CaseLog.new(attributes)
- # case_log.save!
+ case_log = CaseLog.new(attributes)
+ case_log.save!
end
# Safe: A string that represents only an integer (or empty/nil)
diff --git a/config/forms/2021_2022.json b/config/forms/2021_2022.json
index ffb7a043b..8061bc2bd 100644
--- a/config/forms/2021_2022.json
+++ b/config/forms/2021_2022.json
@@ -976,7 +976,7 @@
},
"conditional_for": {
"tenancyother": [
- 4
+ 3
]
}
},
diff --git a/spec/factories/case_log.rb b/spec/factories/case_log.rb
index 4bee0a1f5..45d069af5 100644
--- a/spec/factories/case_log.rb
+++ b/spec/factories/case_log.rb
@@ -20,7 +20,7 @@ FactoryBot.define do
status { 1 }
ecstat1 { 1 }
earnings { 750 }
- incfreq { 0 }
+ incfreq { 1 }
end
trait :conditional_section_complete do
tenant_code { "TH356" }
@@ -50,21 +50,21 @@ FactoryBot.define do
leftreg { 1 }
reservist { 0 }
illness { 0 }
- preg_occ { 1 }
+ preg_occ { 2 }
tenancy_code { "BZ757" }
startertenancy { 0 }
tenancylength { 5 }
- tenancy { 3 }
+ tenancy { 1 }
landlord { 1 }
ppostcode_full { "SE2 6RT" }
- rsnvac { 7 }
- unittype_gn { 2 }
+ rsnvac { 6 }
+ unittype_gn { 7 }
beds { 3 }
voiddate { "03/11/2019" }
offered { 2 }
wchair { 1 }
earnings { 68 }
- incfreq { 0 }
+ incfreq { 1 }
benefits { 1 }
period { 2 }
brent { 200 }
@@ -123,7 +123,7 @@ FactoryBot.define do
incref { 0 }
sale_completion_date { nil }
startdate { Time.utc(2022, 2, 2, 10, 36, 49) }
- armedforces { 0 }
+ armedforces { 1 }
builtype { 1 }
unitletas { 2 }
has_benefits { 1 }
diff --git a/spec/features/form/check_answers_page_spec.rb b/spec/features/form/check_answers_page_spec.rb
index dbeb9fa42..c51e2c1e6 100644
--- a/spec/features/form/check_answers_page_spec.rb
+++ b/spec/features/form/check_answers_page_spec.rb
@@ -113,7 +113,7 @@ RSpec.describe "Form Check Answers Page" do
it "displays conditional question that were visited" do
visit("/logs/#{id}/conditional-question")
- choose("case-log-preg-occ-1-field", allow_label_click: true)
+ choose("case-log-preg-occ-2-field", allow_label_click: true)
click_button("Save and continue")
visit("/logs/#{id}/#{conditional_subsection}/check-answers")
question_labels = ["Has the condition been met?", "Has the condition not been met?"]
diff --git a/spec/features/form/conditional_questions_spec.rb b/spec/features/form/conditional_questions_spec.rb
index db558c93a..9b5c01a20 100644
--- a/spec/features/form/conditional_questions_spec.rb
+++ b/spec/features/form/conditional_questions_spec.rb
@@ -27,11 +27,11 @@ RSpec.describe "Form Conditional Questions" do
it "shows conditional questions if the required answer is selected and hides it again when a different answer option is selected", js: true do
visit("/logs/#{id}/armed-forces")
# Something about our styling makes the selenium webdriver think the actual radio buttons are not visible so we allow label click here
- choose("case-log-armedforces-0-field", allow_label_click: true)
- fill_in("case-log-leftreg-field", with: "text")
choose("case-log-armedforces-1-field", allow_label_click: true)
+ fill_in("case-log-leftreg-field", with: "text")
+ choose("case-log-armedforces-4-field", allow_label_click: true)
expect(page).not_to have_field("case-log-leftreg-field")
- choose("case-log-armedforces-0-field", allow_label_click: true)
+ choose("case-log-armedforces-1-field", allow_label_click: true)
expect(page).to have_field("case-log-leftreg-field", with: "")
end
end
diff --git a/spec/features/form/form_navigation_spec.rb b/spec/features/form/form_navigation_spec.rb
index f62789680..ef8bc7448 100644
--- a/spec/features/form/form_navigation_spec.rb
+++ b/spec/features/form/form_navigation_spec.rb
@@ -71,7 +71,7 @@ RSpec.describe "Form Navigation" do
visit("/logs")
visit("/logs/#{id}/net-income")
fill_in("case-log-earnings-field", with: 740)
- choose("case-log-incfreq-0-field", allow_label_click: true)
+ choose("case-log-incfreq-1-field", allow_label_click: true)
click_button("Save and continue")
click_link(text: "Back")
click_link(text: "Back")
diff --git a/spec/features/form/page_routing_spec.rb b/spec/features/form/page_routing_spec.rb
index d4f50f118..83a1078ff 100644
--- a/spec/features/form/page_routing_spec.rb
+++ b/spec/features/form/page_routing_spec.rb
@@ -24,12 +24,12 @@ RSpec.describe "Form Page Routing" do
visit("/logs/#{id}/conditional-question")
# using a question name that is already in the db to avoid
# having to add a new column to the db for this test
- choose("case-log-preg-occ-0-field", allow_label_click: true)
+ choose("case-log-preg-occ-1-field", allow_label_click: true)
click_button("Save and continue")
expect(page).to have_current_path("/logs/#{id}/conditional-question-yes-page")
click_link(text: "Back")
expect(page).to have_current_path("/logs/#{id}/conditional-question")
- choose("case-log-preg-occ-1-field", allow_label_click: true)
+ choose("case-log-preg-occ-2-field", allow_label_click: true)
click_button("Save and continue")
expect(page).to have_current_path("/logs/#{id}/conditional-question-no-page")
end
@@ -40,7 +40,7 @@ RSpec.describe "Form Page Routing" do
click_button("Save and continue")
expect(page).to have_current_path("/logs/#{id}/person-1-working-situation")
visit("/logs/#{id}/conditional-question")
- choose("case-log-preg-occ-1-field", allow_label_click: true)
+ choose("case-log-preg-occ-2-field", allow_label_click: true)
click_button("Save and continue")
expect(page).to have_current_path("/logs/#{id}/conditional-question-no-page")
click_button("Save and continue")
diff --git a/spec/features/form/validations_spec.rb b/spec/features/form/validations_spec.rb
index b884264a4..75e7f3e99 100644
--- a/spec/features/form/validations_spec.rb
+++ b/spec/features/form/validations_spec.rb
@@ -127,7 +127,7 @@ RSpec.describe "validations" do
it "prompts the user to confirm the value is correct with an interruption screen" do
visit("/logs/#{case_log.id}/net-income")
fill_in("case-log-earnings-field", with: income_over_soft_limit)
- choose("case-log-incfreq-0-field", allow_label_click: true)
+ choose("case-log-incfreq-1-field", allow_label_click: true)
click_button("Save and continue")
expect(page).to have_current_path("/logs/#{case_log.id}/net-income-value-check")
expect(page).to have_content("Net income is outside the expected range based on the lead tenant’s working situation")
@@ -141,7 +141,7 @@ RSpec.describe "validations" do
it "returns the user to the previous question if they do not confirm the value as correct on the interruption screen" do
visit("/logs/#{case_log.id}/net-income")
fill_in("case-log-earnings-field", with: income_over_soft_limit)
- choose("case-log-incfreq-0-field", allow_label_click: true)
+ choose("case-log-incfreq-1-field", allow_label_click: true)
click_button("Save and continue")
choose("case-log-net-income-value-check-1-field", allow_label_click: true)
click_button("Save and continue")
diff --git a/spec/fixtures/complete_case_log.json b/spec/fixtures/complete_case_log.json
index 6f1424b4a..3ae9153c1 100644
--- a/spec/fixtures/complete_case_log.json
+++ b/spec/fixtures/complete_case_log.json
@@ -6,7 +6,7 @@
"ethnic": 0,
"national": 0,
"prevten": 6,
- "armedforces": 0,
+ "armedforces": 1,
"armed_forces_partner": "",
"ecstat1": 1,
"hhmemb": 8,
@@ -43,19 +43,19 @@
"leftreg": 1,
"reservist": 0,
"illness": 0,
- "preg_occ": 0,
+ "preg_occ": 1,
"tenancy_code": "BZ757",
"startdate": "12/12/2021",
"startertenancy": 0,
"tenancylength": 5,
- "tenancy": 3,
+ "tenancy": 1,
"landlord": 1,
"la": "Barnet",
"postcode_full": "NW1 5TY",
"property_relet": 0,
- "rsnvac": 0,
+ "rsnvac": 14,
"property_reference": "P9876",
- "unittype_gn": 2,
+ "unittype_gn": 7,
"property_building_type": "dummy",
"beds": 3,
"voiddate": "10/10/2020",
@@ -65,7 +65,7 @@
"wchair": 1,
"net_income_known": 1,
"earnings": 150,
- "incfreq": 0,
+ "incfreq": 1,
"benefits": 1,
"hb": 1,
"period": 2,
diff --git a/spec/fixtures/exports/case_logs.xml b/spec/fixtures/exports/case_logs.xml
index e5a2b16d7..e30083c94 100644
--- a/spec/fixtures/exports/case_logs.xml
+++ b/spec/fixtures/exports/case_logs.xml
@@ -39,20 +39,20 @@
1
0
0
- 1
+ 2
BZ757
0
5
- 3
+ 1
1
SE26RT
- 7
- 2
+ 6
+ 7
3
2
1
68
- 0
+ 1
1
2
2
@@ -103,7 +103,7 @@
0
2022-02-02 10:36:49 UTC
- 0
+ 1
2
1
diff --git a/spec/fixtures/forms/2021_2022.json b/spec/fixtures/forms/2021_2022.json
index 16a9efbf7..032448ca1 100644
--- a/spec/fixtures/forms/2021_2022.json
+++ b/spec/fixtures/forms/2021_2022.json
@@ -225,24 +225,24 @@
"type": "radio",
"check_answer_label": "Household links to UK armed forces",
"answer_options": {
- "0": {
+ "1": {
"value": "Yes, the person is a current or former regular"
},
- "1": {
+ "4": {
"value": "Yes, the person is a current or former reserve"
},
- "2": {
+ "5": {
"value": "Yes, the tenant is a spouse or civil partner of a UK armed forces member and has been bereaved or separated from them within the last 2 years"
},
- "3": {
+ "2": {
"value": "No"
},
- "4": {
+ "3": {
"value": "Person prefers not to say"
}
},
"conditional_for": {
- "leftreg": [0]
+ "leftreg": [1]
}
},
"leftreg": {
@@ -463,10 +463,10 @@
"header": "Has the condition been met?",
"type": "radio",
"answer_options": {
- "0": {
+ "1": {
"value": "Yes"
},
- "1": {
+ "2": {
"value": "No"
}
}
@@ -486,7 +486,7 @@
}
}
},
- "depends_on": [{ "preg_occ": 0 }, { "wchair" : 1 }]
+ "depends_on": [{ "preg_occ": 1 }, { "wchair" : 1 }]
},
"conditional_question_no_page": {
"questions": {
@@ -504,7 +504,7 @@
}
}
},
- "depends_on": [{ "preg_occ": 1 }]
+ "depends_on": [{ "preg_occ": 2 }]
},
"conditional_question_no_second_page": {
"questions": {
@@ -522,7 +522,7 @@
}
}
},
- "depends_on": [{ "preg_occ": 1, "sex1": "M" }]
+ "depends_on": [{ "preg_occ": 2, "sex1": "M" }]
}
}
}
@@ -548,9 +548,9 @@
"width": 5,
"prefix": "£",
"suffix": [
- { "label": "every week", "depends_on" : { "incfreq": 0 } },
- { "label": "every month", "depends_on" : { "incfreq": 1 } },
- { "label": "every month", "depends_on" : { "incfreq": 2 } }
+ { "label": "every week", "depends_on" : { "incfreq": 1 } },
+ { "label": "every month", "depends_on" : { "incfreq": 2 } },
+ { "label": "every month", "depends_on" : { "incfreq": 3 } }
]
},
"incfreq": {
@@ -558,13 +558,13 @@
"header": "How often do they receive this income?",
"type": "radio",
"answer_options": {
- "0": {
+ "1": {
"value": "Weekly"
},
- "1": {
+ "2": {
"value": "Monthly"
},
- "2": {
+ "3": {
"value": "Yearly"
}
}
@@ -646,7 +646,7 @@
}
},
"dependent_page": {
- "depends_on": [{ "incfreq": 0 }],
+ "depends_on": [{ "incfreq": 1 }],
"questions": {
"dependent_question": {
"check_answer_label": "Dependent Question",
diff --git a/spec/helpers/conditional_questions_helper_spec.rb b/spec/helpers/conditional_questions_helper_spec.rb
index 919984a09..ab3898ea0 100644
--- a/spec/helpers/conditional_questions_helper_spec.rb
+++ b/spec/helpers/conditional_questions_helper_spec.rb
@@ -14,7 +14,7 @@ RSpec.describe ConditionalQuestionsHelper do
describe "find conditional question" do
let(:question) { page.questions.find { |q| q.id == "armedforces" } }
- let(:answer_value) { 0 }
+ let(:answer_value) { 1 }
it "returns the conditional question for a given answer option" do
expect(find_conditional_question(page, question, answer_value).id).to eq("leftreg")
diff --git a/spec/helpers/interuption_screen_helper_spec.rb b/spec/helpers/interuption_screen_helper_spec.rb
index efcf4d1e2..cb2fc3520 100644
--- a/spec/helpers/interuption_screen_helper_spec.rb
+++ b/spec/helpers/interuption_screen_helper_spec.rb
@@ -11,7 +11,7 @@ RSpec.describe InteruptionScreenHelper do
:in_progress,
ecstat1: 1,
earnings: 750,
- incfreq: 0,
+ incfreq: 1,
owning_organisation: user.organisation,
managing_organisation: user.organisation,
)
diff --git a/spec/models/case_log_spec.rb b/spec/models/case_log_spec.rb
index 268c65558..67c8446b6 100644
--- a/spec/models/case_log_spec.rb
+++ b/spec/models/case_log_spec.rb
@@ -175,17 +175,17 @@ RSpec.describe CaseLog do
let(:case_log) { FactoryBot.build(:case_log, earnings: net_income) }
it "returns input income if frequency is already weekly" do
- case_log.incfreq = 0
+ case_log.incfreq = 1
expect(case_log.weekly_net_income).to eq(net_income)
end
it "calculates the correct weekly income from monthly income" do
- case_log.incfreq = 1
+ case_log.incfreq = 2
expect(case_log.weekly_net_income).to eq(1154)
end
it "calculates the correct weekly income from yearly income" do
- case_log.incfreq = 2
+ case_log.incfreq = 3
expect(case_log.weekly_net_income).to eq(417)
end
end
@@ -1663,7 +1663,7 @@ RSpec.describe CaseLog do
describe "resetting invalidated fields" do
context "when a question that has already been answered, no longer has met dependencies" do
- let(:case_log) { FactoryBot.create(:case_log, :in_progress, cbl: 1, preg_occ: 1, wchair: 1) }
+ let(:case_log) { FactoryBot.create(:case_log, :in_progress, cbl: 1, preg_occ: 2, wchair: 1) }
it "clears the answer" do
expect { case_log.update!(preg_occ: nil) }.to change(case_log, :cbl).from(1).to(nil)
@@ -1679,7 +1679,7 @@ RSpec.describe CaseLog do
end
context "with two pages having the same question key, only one's dependency is met" do
- let(:case_log) { FactoryBot.create(:case_log, :in_progress, cbl: 0, preg_occ: 1, wchair: 1) }
+ let(:case_log) { FactoryBot.create(:case_log, :in_progress, cbl: 0, preg_occ: 2, wchair: 1) }
it "does not clear the value for answers that apply to both pages" do
expect(case_log.cbl).to eq(0)
@@ -1688,7 +1688,7 @@ RSpec.describe CaseLog do
it "does clear the value for answers that do not apply for invalidated page" do
case_log.update!({ wchair: 1, sex2: "F", age2: 33 })
case_log.update!({ cbl: 1 })
- case_log.update!({ preg_occ: 0 })
+ case_log.update!({ preg_occ: 1 })
expect(case_log.cbl).to eq(nil)
end
diff --git a/spec/models/form/page_spec.rb b/spec/models/form/page_spec.rb
index a09fcace6..57c9393b3 100644
--- a/spec/models/form/page_spec.rb
+++ b/spec/models/form/page_spec.rb
@@ -56,7 +56,7 @@ RSpec.describe Form::Page, type: :model do
end
it "evaluates met conditions correctly" do
- case_log.incfreq = "Weekly"
+ case_log.incfreq = 1
expect(page.routed_to?(case_log)).to be true
end
end
diff --git a/spec/models/form/question_spec.rb b/spec/models/form/question_spec.rb
index 94d65652a..13b2d7c1a 100644
--- a/spec/models/form/question_spec.rb
+++ b/spec/models/form/question_spec.rb
@@ -75,16 +75,16 @@ RSpec.describe Form::Question, type: :model do
let(:question_id) { "incfreq" }
it "has answer options" do
- expected_answer_options = { "0" => { "value" => "Weekly" }, "1" => { "value" => "Monthly" }, "2" => { "value" => "Yearly" } }
+ expected_answer_options = { "1" => { "value" => "Weekly" }, "2" => { "value" => "Monthly" }, "3" => { "value" => "Yearly" } }
expect(question.answer_options).to eq(expected_answer_options)
end
it "can map value from label" do
- expect(question.value_from_label("Monthly")).to eq("1")
+ expect(question.value_from_label("Monthly")).to eq("2")
end
it "can map label from value" do
- expect(question.label_from_value(2)).to eq("Yearly")
+ expect(question.label_from_value(3)).to eq("Yearly")
end
context "when answer options include yes, no, prefer not to say" do
@@ -221,7 +221,7 @@ RSpec.describe Form::Question, type: :model do
let(:question_id) { "incfreq" }
it "has an answer label" do
- case_log.incfreq = 0
+ case_log.incfreq = 1
expect(question.answer_label(case_log)).to eq("Weekly")
end
@@ -321,12 +321,12 @@ RSpec.describe Form::Question, type: :model do
let(:question_id) { "earnings" }
it "displays the correct label for given suffix and answer the suffix depends on" do
- case_log.incfreq = 0
+ case_log.incfreq = 1
case_log.earnings = 500
expect(question.answer_label(case_log)).to eq("£500.00 every week")
- case_log.incfreq = 1
- expect(question.answer_label(case_log)).to eq("£500.00 every month")
case_log.incfreq = 2
+ expect(question.answer_label(case_log)).to eq("£500.00 every month")
+ case_log.incfreq = 3
expect(question.answer_label(case_log)).to eq("£500.00 every year")
end
end
diff --git a/spec/models/form_spec.rb b/spec/models/form_spec.rb
index 3e1c7dbf9..9bc9369db 100644
--- a/spec/models/form_spec.rb
+++ b/spec/models/form_spec.rb
@@ -16,7 +16,7 @@ RSpec.describe Form, type: :model do
context "when the current page is a value check page" do
before do
- case_log.incfreq = 0
+ case_log.incfreq = 1
case_log.earnings = 140
case_log.ecstat1 = 1
end
@@ -39,7 +39,7 @@ RSpec.describe Form, type: :model do
let!(:page_ids) { subsection.pages.map(&:id) }
before do
- case_log.preg_occ = 1
+ case_log.preg_occ = 2
end
it "returns the previous page if the page is routed to" do
@@ -68,7 +68,7 @@ RSpec.describe Form, type: :model do
end
it "returns a correct page path if there is conditional routing" do
- case_log["preg_occ"] = 1
+ case_log["preg_occ"] = 2
expect(form.next_page_redirect_path(previous_conditional_page, case_log)).to eq("case_log_conditional_question_no_page_path")
end
end
@@ -102,7 +102,7 @@ RSpec.describe Form, type: :model do
def answer_income_and_benefits(case_log)
case_log.earnings = 30_000
- case_log.incfreq = "Yearly"
+ case_log.incfreq = 3
case_log.benefits = "Some"
case_log.hb = "Tenant prefers not to say"
end
diff --git a/spec/models/validations/financial_validations_spec.rb b/spec/models/validations/financial_validations_spec.rb
index 59299e62a..2ab76fb1b 100644
--- a/spec/models/validations/financial_validations_spec.rb
+++ b/spec/models/validations/financial_validations_spec.rb
@@ -17,7 +17,7 @@ RSpec.describe Validations::FinancialValidations do
it "when income frequency is provided it validates that earnings must be provided" do
record.earnings = nil
- record.incfreq = 0
+ record.incfreq = 1
financial_validator.validate_net_income(record)
expect(record.errors["earnings"])
.to include(match I18n.t("validations.financial.earnings.earnings_missing"))
@@ -124,7 +124,7 @@ RSpec.describe Validations::FinancialValidations do
describe "Net income validations" do
it "validates that the net income is within the expected range for the tenant's employment status" do
record.earnings = 200
- record.incfreq = 0
+ record.incfreq = 1
record.ecstat1 = 1
financial_validator.validate_net_income(record)
expect(record.errors["earnings"]).to be_empty
@@ -133,7 +133,7 @@ RSpec.describe Validations::FinancialValidations do
context "when the net income is higher than the hard max for their employment status" do
it "adds an error" do
record.earnings = 5000
- record.incfreq = 0
+ record.incfreq = 1
record.ecstat1 = 1
financial_validator.validate_net_income(record)
expect(record.errors["earnings"])
@@ -144,7 +144,7 @@ RSpec.describe Validations::FinancialValidations do
context "when the net income is lower than the hard min for their employment status" do
it "adds an error" do
record.earnings = 50
- record.incfreq = 0
+ record.incfreq = 1
record.ecstat1 = 1
financial_validator.validate_net_income(record)
expect(record.errors["earnings"])
diff --git a/spec/models/validations/household_validations_spec.rb b/spec/models/validations/household_validations_spec.rb
index 11c856e52..80ec840ce 100644
--- a/spec/models/validations/household_validations_spec.rb
+++ b/spec/models/validations/household_validations_spec.rb
@@ -58,7 +58,7 @@ RSpec.describe Validations::HouseholdValidations do
describe "pregnancy validations" do
context "when there are no female tenants" do
it "validates that pregnancy cannot be yes" do
- record.preg_occ = 0
+ record.preg_occ = 1
record.sex1 = "M"
household_validator.validate_pregnancy(record)
expect(record.errors["preg_occ"])
@@ -66,7 +66,7 @@ RSpec.describe Validations::HouseholdValidations do
end
it "validates that pregnancy cannot be prefer not to say" do
- record.preg_occ = 2
+ record.preg_occ = 3
record.sex1 = "M"
household_validator.validate_pregnancy(record)
expect(record.errors["preg_occ"])
@@ -77,7 +77,7 @@ RSpec.describe Validations::HouseholdValidations do
context "when there are female tenants" do
context "but they are older than 50" do
it "validates that pregnancy cannot be yes" do
- record.preg_occ = 0
+ record.preg_occ = 1
record.sex1 = "F"
record.age1 = 51
household_validator.validate_pregnancy(record)
@@ -248,7 +248,7 @@ RSpec.describe Validations::HouseholdValidations do
context "when the tenant prefers not to say if they were or are in the armed forces" do
it "validates that injured in the armed forces is not yes" do
- record.armedforces = 4
+ record.armedforces = 3
record.reservist = 0
household_validator.validate_armed_forces(record)
expect(record.errors["reservist"])
@@ -276,7 +276,7 @@ RSpec.describe Validations::HouseholdValidations do
context "when the tenant's partner was or is a member of the armed forces" do
it "expects that injured in the armed forces can be yes" do
- record.armedforces = 2
+ record.armedforces = 5
record.reservist = 0
household_validator.validate_armed_forces(record)
expect(record.errors["reservist"]).to be_empty
@@ -285,7 +285,7 @@ RSpec.describe Validations::HouseholdValidations do
context "when the tenant or partner has left the armed forces" do
it "validates that they served in the armed forces" do
- record.armedforces = 3
+ record.armedforces = 2
record.leftreg = 0
household_validator.validate_armed_forces(record)
expect(record.errors["leftreg"])
@@ -293,14 +293,14 @@ RSpec.describe Validations::HouseholdValidations do
end
it "expects that they served in the armed forces" do
- record.armedforces = 0
+ record.armedforces = 1
record.leftreg = 0
household_validator.validate_armed_forces(record)
expect(record.errors["leftreg"]).to be_empty
end
it "expects that they served in the armed forces and may have been injured" do
- record.armedforces = 0
+ record.armedforces = 1
record.leftreg = 0
record.reservist = 0
household_validator.validate_armed_forces(record)
@@ -697,7 +697,7 @@ RSpec.describe Validations::HouseholdValidations do
describe "previous housing situation validations" do
context "when the property is being relet to a previously temporary tenant" do
it "validates that previous tenancy was temporary" do
- record.rsnvac = 2
+ record.rsnvac = 9
record.prevten = 4
household_validator.validate_previous_housing_situation(record)
expect(record.errors["prevten"])
diff --git a/spec/models/validations/property_validations_spec.rb b/spec/models/validations/property_validations_spec.rb
index d2c34a613..08052ee7e 100644
--- a/spec/models/validations/property_validations_spec.rb
+++ b/spec/models/validations/property_validations_spec.rb
@@ -43,7 +43,7 @@ RSpec.describe Validations::PropertyValidations do
context "when number of bedrooms has not been answered" do
it "does not add an error" do
record.beds = nil
- record.unittype_gn = 1
+ record.unittype_gn = 2
property_validator.validate_shared_housing_rooms(record)
expect(record.errors).to be_empty
end
@@ -52,7 +52,7 @@ RSpec.describe Validations::PropertyValidations do
context "when unit type is shared and number of bedrooms has not been answered" do
it "does not add an error" do
record.beds = nil
- record.unittype_gn = 6
+ record.unittype_gn = 10
property_validator.validate_shared_housing_rooms(record)
expect(record.errors).to be_empty
end
@@ -72,7 +72,7 @@ RSpec.describe Validations::PropertyValidations do
it "adds an error" do
record.beds = 2
- record.unittype_gn = 1
+ record.unittype_gn = 2
property_validator.validate_shared_housing_rooms(record)
expect(record.errors["unittype_gn"]).to include(match(expected_error))
expect(record.errors["beds"]).to include(I18n.t("validations.property.unittype_gn.one_bedroom_bedsit"))
@@ -84,7 +84,7 @@ RSpec.describe Validations::PropertyValidations do
it "adds an error" do
record.beds = 0
- record.unittype_gn = 1
+ record.unittype_gn = 2
property_validator.validate_shared_housing_rooms(record)
expect(record.errors["unittype_gn"]).to include(match(expected_error))
expect(record.errors["beds"]).to include(I18n.t("validations.property.unittype_gn.one_bedroom_bedsit"))
@@ -96,7 +96,7 @@ RSpec.describe Validations::PropertyValidations do
it "adds an error if the number of bedrooms is not between 1 and 7" do
record.beds = 8
- record.unittype_gn = 5
+ record.unittype_gn = 9
record.hhmemb = 3
property_validator.validate_shared_housing_rooms(record)
expect(record.errors["unittype_gn"]).to include(match(expected_error))
@@ -109,7 +109,7 @@ RSpec.describe Validations::PropertyValidations do
it "adds an error if the number of bedrooms is not between 1 and 7" do
record.beds = 0
- record.unittype_gn = 5
+ record.unittype_gn = 9
record.hhmemb = 3
property_validator.validate_shared_housing_rooms(record)
expect(record.errors["unittype_gn"]).to include(match(expected_error))
@@ -122,7 +122,7 @@ RSpec.describe Validations::PropertyValidations do
it "adds an error" do
record.beds = 4
- record.unittype_gn = 5
+ record.unittype_gn = 9
record.hhmemb = 1
property_validator.validate_shared_housing_rooms(record)
expect(record.errors["unittype_gn"]).to include(match(expected_error))
@@ -286,7 +286,7 @@ RSpec.describe Validations::PropertyValidations do
it "validates that the property is not being relet to tenant who occupied as temporary" do
non_temporary_previous_tenancies.each do |prevten|
- record.rsnvac = 2
+ record.rsnvac = 9
record.prevten = prevten
property_validator.validate_rsnvac(record)
expect(record.errors["rsnvac"])
@@ -296,7 +296,7 @@ RSpec.describe Validations::PropertyValidations do
it "validates that the letting source is not a referral" do
referral_sources.each do |src|
- record.rsnvac = 2
+ record.rsnvac = 9
record.referral = src
property_validator.validate_rsnvac(record)
expect(record.errors["rsnvac"])
diff --git a/spec/models/validations/tenancy_validations_spec.rb b/spec/models/validations/tenancy_validations_spec.rb
index 689a7f383..4baaf6445 100644
--- a/spec/models/validations/tenancy_validations_spec.rb
+++ b/spec/models/validations/tenancy_validations_spec.rb
@@ -12,7 +12,7 @@ RSpec.describe Validations::TenancyValidations do
let(:expected_error) { I18n.t("validations.tenancy.length.fixed_term_not_required") }
it "tenancy length should not be present" do
- record.tenancy = 4
+ record.tenancy = 3
record.tenancylength = 10
tenancy_validator.validate_fixed_term_tenancy(record)
expect(record.errors["tenancylength"]).to include(match(expected_error))
@@ -22,10 +22,10 @@ RSpec.describe Validations::TenancyValidations do
context "when type of tenancy is assured shorthold" do
let(:expected_error) { I18n.t("validations.tenancy.length.shorthold") }
+ before { record.tenancy = 4 }
context "when tenancy length is greater than 1" do
it "adds an error" do
- record.tenancy = 1
record.tenancylength = 1
tenancy_validator.validate_fixed_term_tenancy(record)
expect(record.errors["tenancylength"]).to include(match(expected_error))
@@ -35,7 +35,6 @@ RSpec.describe Validations::TenancyValidations do
context "when tenancy length is less than 100" do
it "adds an error" do
- record.tenancy = 1
record.tenancylength = 100
tenancy_validator.validate_fixed_term_tenancy(record)
expect(record.errors["tenancylength"]).to include(match(expected_error))
@@ -45,7 +44,6 @@ RSpec.describe Validations::TenancyValidations do
context "when tenancy length is between 2-99" do
it "does not add an error" do
- record.tenancy = 1
record.tenancylength = 3
tenancy_validator.validate_fixed_term_tenancy(record)
expect(record.errors["tenancylength"]).to be_empty
@@ -55,7 +53,6 @@ RSpec.describe Validations::TenancyValidations do
context "when tenancy length has not been answered" do
it "does not add an error" do
- record.tenancy = 1
record.tenancylength = nil
tenancy_validator.validate_fixed_term_tenancy(record)
expect(record.errors["tenancylength"]).to be_empty
@@ -66,10 +63,10 @@ RSpec.describe Validations::TenancyValidations do
context "when type of tenancy is secure" do
let(:expected_error) { I18n.t("validations.tenancy.length.secure") }
+ before { record.tenancy = 1 }
context "when tenancy length is greater than 1" do
it "adds an error" do
- record.tenancy = 3
record.tenancylength = 1
tenancy_validator.validate_fixed_term_tenancy(record)
expect(record.errors["tenancylength"]).to include(match(expected_error))
@@ -79,7 +76,6 @@ RSpec.describe Validations::TenancyValidations do
context "when tenancy length is less than 100" do
it "adds an error" do
- record.tenancy = 3
record.tenancylength = 100
tenancy_validator.validate_fixed_term_tenancy(record)
expect(record.errors["tenancylength"]).to include(match(expected_error))
@@ -89,7 +85,6 @@ RSpec.describe Validations::TenancyValidations do
context "when tenancy length is between 2-99" do
it "does not add an error" do
- record.tenancy = 3
record.tenancylength = 3
tenancy_validator.validate_fixed_term_tenancy(record)
expect(record.errors["tenancylength"]).to be_empty
@@ -99,7 +94,6 @@ RSpec.describe Validations::TenancyValidations do
context "when tenancy length has not been answered" do
it "does not add an error" do
- record.tenancy = 3
record.tenancylength = nil
tenancy_validator.validate_fixed_term_tenancy(record)
expect(record.errors["tenancylength"]).to be_empty
@@ -117,15 +111,15 @@ RSpec.describe Validations::TenancyValidations do
let(:expected_error) { I18n.t(field, main_field_label:, other_field_label:) }
context "when tenancy type is other" do
+ before { record.tenancy = 3 }
+
it "validates that other tenancy type is provided" do
- record.tenancy = 4
record.tenancyother = nil
tenancy_validator.validate_other_tenancy_type(record)
expect(record.errors[other_field_label]).to include(match(expected_error))
end
it "expects that other tenancy type is provided" do
- record.tenancy = 4
record.tenancyother = "Some other tenancy type"
tenancy_validator.validate_other_tenancy_type(record)
expect(record.errors[other_field_label]).to be_empty
@@ -136,14 +130,14 @@ RSpec.describe Validations::TenancyValidations do
let(:field) { "validations.other_field_not_required" }
it "validates that other tenancy type is not provided" do
- record.tenancy = 0
+ record.tenancy = 2
record.tenancyother = "Some other tenancy type"
tenancy_validator.validate_other_tenancy_type(record)
expect(record.errors[other_field_label]).to include(match(expected_error))
end
it "expects that other tenancy type is not provided" do
- record.tenancy = 3
+ record.tenancy = 1
record.tenancyother = nil
tenancy_validator.validate_other_tenancy_type(record)
expect(record.errors[other_field_label]).to be_empty
diff --git a/spec/requests/form_controller_spec.rb b/spec/requests/form_controller_spec.rb
index 8190d2464..8e99f7e78 100644
--- a/spec/requests/form_controller_spec.rb
+++ b/spec/requests/form_controller_spec.rb
@@ -275,7 +275,7 @@ RSpec.describe FormController, type: :request do
id: case_log.id,
case_log: {
page: "conditional_question",
- preg_occ: 0,
+ preg_occ: 1,
},
}
end
@@ -284,7 +284,7 @@ RSpec.describe FormController, type: :request do
id: case_log.id,
case_log: {
page: "conditional_question",
- preg_occ: 1,
+ preg_occ: 2,
},
}
end
diff --git a/spec/services/imports/case_logs_import_service_spec.rb b/spec/services/imports/case_logs_import_service_spec.rb
index 7af288654..f1c1dfe34 100644
--- a/spec/services/imports/case_logs_import_service_spec.rb
+++ b/spec/services/imports/case_logs_import_service_spec.rb
@@ -24,6 +24,7 @@ RSpec.describe Imports::CaseLogsImportService do
it "successfully create a case log with the expected data" do
case_log_service.create_logs(remote_folder)
+
end
end
end