diff --git a/app/models/case_log.rb b/app/models/case_log.rb index 5553b5a78..f73df0264 100644 --- a/app/models/case_log.rb +++ b/app/models/case_log.rb @@ -230,7 +230,7 @@ private dynamically_not_required << "incfreq" end - if tenancy == "Fixed term – Secure" + if tenancy == "Secure (including flexible)" dynamically_not_required << "tenancylength" end diff --git a/app/validations/tenancy_validations.rb b/app/validations/tenancy_validations.rb index 32ff8e2b0..fc275f91e 100644 --- a/app/validations/tenancy_validations.rb +++ b/app/validations/tenancy_validations.rb @@ -4,12 +4,12 @@ module TenancyValidations def validate_fixed_term_tenancy(record) is_present = record.tenancylength.present? is_in_range = record.tenancylength.to_i.between?(2, 99) - is_secure = record.tenancy == "Fixed term – Secure" - is_ast = record.tenancy == "Fixed term – Assured Shorthold Tenancy (AST)" + is_secure = record.tenancy == "Secure (including flexible)" + is_ast = record.tenancy == "Assured Shorthold" conditions = [ { condition: !(is_secure || is_ast) && is_present, error: "You must only answer the fixed term tenancy length question if the tenancy type is fixed term" }, { condition: is_ast && !is_in_range, error: "Fixed term – Assured Shorthold Tenancy (AST) should be between 2 and 99 years" }, - { condition: is_secure && (!is_in_range && is_present), error: "Fixed term – Secure should be between 2 and 99 years or not specified" }, + { condition: is_secure && (!is_in_range && is_present), error: "Secure (including flexible) should be between 2 and 99 years or not specified" }, ] conditions.each { |condition| condition[:condition] ? (record.errors.add :tenancylength, condition[:error]) : nil } diff --git a/docs/api/DLUHC-CORE-Data.v1.json b/docs/api/DLUHC-CORE-Data.v1.json index 17560d14c..5723c9311 100644 --- a/docs/api/DLUHC-CORE-Data.v1.json +++ b/docs/api/DLUHC-CORE-Data.v1.json @@ -306,7 +306,7 @@ "startdate": "12/03/2019", "startertenancy": "No", "tenancylength": "No", - "tenancy": "Fixed term – Secure", + "tenancy": "Secure (including flexible)", "lettype": "Affordable Rent - General Needs", "landlord": "This landlord", "la": "Barnet", diff --git a/spec/fixtures/complete_case_log.json b/spec/fixtures/complete_case_log.json index 4656a04f8..81f2735fc 100644 --- a/spec/fixtures/complete_case_log.json +++ b/spec/fixtures/complete_case_log.json @@ -52,7 +52,7 @@ "startdate": "12/03/2019", "startertenancy": "No", "tenancylength": "5", - "tenancy": "Fixed term – Secure", + "tenancy": "Secure (including flexible)", "lettype": "Affordable Rent - General Needs", "landlord": "This landlord", "la": "Barnet", diff --git a/spec/models/case_log_spec.rb b/spec/models/case_log_spec.rb index e663937db..fad6ca4b9 100644 --- a/spec/models/case_log_spec.rb +++ b/spec/models/case_log_spec.rb @@ -182,39 +182,39 @@ RSpec.describe Form, type: :model do it "Must be completed and between 2 and 99 if type of tenancy is Assured shorthold" do expect { - CaseLog.create!(tenancy: "Fixed term – Assured Shorthold Tenancy (AST)", + CaseLog.create!(tenancy: "Assured Shorthold", tenancylength: 1) }.to raise_error(ActiveRecord::RecordInvalid) expect { - CaseLog.create!(tenancy: "Fixed term – Assured Shorthold Tenancy (AST)", + CaseLog.create!(tenancy: "Assured Shorthold", tenancylength: nil) }.to raise_error(ActiveRecord::RecordInvalid) expect { - CaseLog.create!(tenancy: "Fixed term – Assured Shorthold Tenancy (AST)", + CaseLog.create!(tenancy: "Assured Shorthold", tenancylength: 2) }.not_to raise_error end it "Must be empty or between 2 and 99 if type of tenancy is Secure" do expect { - CaseLog.create!(tenancy: "Fixed term – Secure", + CaseLog.create!(tenancy: "Secure (including flexible)", tenancylength: 1) }.to raise_error(ActiveRecord::RecordInvalid) expect { - CaseLog.create!(tenancy: "Fixed term – Secure", + CaseLog.create!(tenancy: "Secure (including flexible)", tenancylength: 100) }.to raise_error(ActiveRecord::RecordInvalid) expect { - CaseLog.create!(tenancy: "Fixed term – Secure", + CaseLog.create!(tenancy: "Secure (including flexible)", tenancylength: nil) }.not_to raise_error expect { - CaseLog.create!(tenancy: "Fixed term – Secure", + CaseLog.create!(tenancy: "Secure (including flexible)", tenancylength: 2) }.not_to raise_error end @@ -294,12 +294,12 @@ RSpec.describe Form, type: :model do it "must not be provided if tenancy type is not other" do expect { - CaseLog.create!(tenancy: "Fixed term – Secure", + CaseLog.create!(tenancy: "Secure (including flexible)", tenancyother: "the other reason provided") }.to raise_error(ActiveRecord::RecordInvalid) expect { - CaseLog.create!(tenancy: "Fixed term – Secure", + CaseLog.create!(tenancy: "Secure (including flexible)", tenancyother: nil) }.not_to raise_error end