Browse Source

CLDC-3892 Update BU prevten valid value validation with custom message (#3050)

* Update wording in testing tools section for clarity

* Add validation for previous tenancy value when renewal is indicated

* Add tests for prevten bu validation in renewal logs

* Update spec/services/bulk_upload/lettings/year2024/row_parser_spec.rb

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* Update spec/services/bulk_upload/lettings/year2025/row_parser_spec.rb

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

---------

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
main v0.5.10
Manny Dinssa 1 week ago committed by GitHub
parent
commit
9c22fd469c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 2
      app/components/create_log_actions_component.html.erb
  2. 8
      app/services/bulk_upload/lettings/year2024/row_parser.rb
  3. 8
      app/services/bulk_upload/lettings/year2025/row_parser.rb
  4. 2
      config/locales/validations/lettings/2024/bulk_upload.en.yml
  5. 2
      config/locales/validations/lettings/2025/bulk_upload.en.yml
  6. 21
      spec/services/bulk_upload/lettings/year2024/row_parser_spec.rb
  7. 21
      spec/services/bulk_upload/lettings/year2025/row_parser_spec.rb

2
app/components/create_log_actions_component.html.erb

@ -11,7 +11,7 @@
<% if FeatureToggle.create_test_logs_enabled? %>
<div class="govuk-inset-text app-testing-tools__inset">
<span class="govuk-tag app-testing-tools__tag">Testing tools</span>
<span class="govuk-body govuk-body-s">These options can only be seen and used in testing environments.</span>
<span class="govuk-body govuk-body-s">These tools can only be seen and used in testing environments.</span>
<div>
<%= govuk_button_link_to create_test_log_href, class: "govuk-button" do %>
New test log

8
app/services/bulk_upload/lettings/year2024/row_parser.rb

@ -445,6 +445,7 @@ class BulkUpload::Lettings::Year2024::RowParser
validate :validate_incomplete_soft_validations, on: :after_log
validate :validate_nationality, on: :after_log
validate :validate_reasonpref_reason_values, on: :after_log
validate :validate_prevten_value_when_renewal, on: :after_log
validate :validate_nulls, on: :after_log
@ -674,6 +675,13 @@ private
end
end
def validate_prevten_value_when_renewal
return unless field_7 == 1
return if field_100.blank? || [6, 30, 31, 32, 33, 34, 35, 36].include?(field_100)
errors.add(:field_100, I18n.t("#{ERROR_BASE_KEY}.prevten.invalid"))
end
def duplicate_check_fields
[
"startdate",

8
app/services/bulk_upload/lettings/year2025/row_parser.rb

@ -444,6 +444,7 @@ class BulkUpload::Lettings::Year2025::RowParser
validate :validate_incomplete_soft_validations, on: :after_log
validate :validate_nationality, on: :after_log
validate :validate_reasonpref_reason_values, on: :after_log
validate :validate_prevten_value_when_renewal, on: :after_log
validate :validate_nulls, on: :after_log
@ -673,6 +674,13 @@ private
end
end
def validate_prevten_value_when_renewal
return unless field_7 == 1
return if field_100.blank? || [6, 30, 31, 32, 33, 34, 35, 38].include?(field_100)
errors.add(:field_100, I18n.t("#{ERROR_BASE_KEY}.prevten.invalid"))
end
def duplicate_check_fields
[
"startdate",

2
config/locales/validations/lettings/2024/bulk_upload.en.yml

@ -62,3 +62,5 @@ en:
conflict:
dont_know: "You cannot select 'Don't know' if any of the other reasonable preference reasons are also selected."
other: "You cannot select this reasonable preference reason as you've also selected 'Don't know' as a reason."
prevten:
invalid: "You said this letting is a renewal to the same tenant in the same property in the set up section. This means where the household was immediately before this letting must be \"Fixed-term local authority general needs tenancy\", \"Fixed-term private registered provider (PRP) general needs tenancy\", \"Lifetime local authority general needs tenancy\", \"Lifetime private registered provider (PRP) general needs tenancy\", \"Extra care housing\", \"Specialist retirement housing\", \"Sheltered housing for adults under 55 years\" or \"Other supported housing.\""

2
config/locales/validations/lettings/2025/bulk_upload.en.yml

@ -62,3 +62,5 @@ en:
conflict:
dont_know: "You cannot select 'Don't know' if any of the other reasonable preference reasons are also selected."
other: "You cannot select this reasonable preference reason as you've also selected 'Don't know' as a reason."
prevten:
invalid: "You said this letting is a renewal to the same tenant in the same property in the set up section. This means where the household was immediately before this letting must be \"Fixed-term local authority general needs tenancy\", \"Fixed-term private registered provider (PRP) general needs tenancy\", \"Lifetime local authority general needs tenancy\", \"Lifetime private registered provider (PRP) general needs tenancy\", \"Extra care housing\", \"Older people's housing for tenants with low support needs\" or \"Other supported housing.\""

21
spec/services/bulk_upload/lettings/year2024/row_parser_spec.rb

@ -1216,6 +1216,27 @@ RSpec.describe BulkUpload::Lettings::Year2024::RowParser do
end
end
describe "#field_100" do
context "when log is a renewal and field 100 is an invalid value" do
let(:attributes) { { bulk_upload:, field_7: 1, field_100: 5 } }
it "adds an error to field 100" do
parser.valid?
expect(parser.errors[:field_100]).to be_present
expect(parser.errors[:field_100]).to include(I18n.t("validations.lettings.2024.bulk_upload.prevten.invalid"))
end
end
context "when log is a renewal and field 100 is a valid value" do
let(:attributes) { { bulk_upload:, field_7: 1, field_100: 32 } }
it "does not add an error" do
parser.valid?
expect(parser.errors[:field_100]).to be_blank
end
end
end
describe "#field_112 - 115 (lettings allocation methods)" do
%i[field_112 field_113 field_114 field_115].each do |field|
context "when only #{field} is not given" do

21
spec/services/bulk_upload/lettings/year2025/row_parser_spec.rb

@ -1053,6 +1053,27 @@ RSpec.describe BulkUpload::Lettings::Year2025::RowParser do
end
end
describe "#field_100" do
context "when log is a renewal and field 100 is an invalid value" do
let(:attributes) { { bulk_upload:, field_7: 1, field_100: 4 } }
it "adds an error to field 100" do
parser.valid?
expect(parser.errors[:field_100]).to be_present
expect(parser.errors[:field_100]).to include(I18n.t("validations.lettings.2025.bulk_upload.prevten.invalid"))
end
end
context "when log is a renewal and field 100 is a valid value" do
let(:attributes) { { bulk_upload:, field_7: 1, field_100: 38 } }
it "does not add an error" do
parser.valid?
expect(parser.errors[:field_100]).to be_blank
end
end
end
describe "#field_112 - 115 (lettings allocation methods)" do
%i[field_112 field_113 field_114 field_115].each do |field|
context "when only #{field} is not given" do

Loading…
Cancel
Save