Browse Source

Correct 24/25 bulk upload error messages on lettings and sales

pull/2553/head
Manny Dinssa 2 years ago
parent
commit
ac9e0202e4
  1. 3
      app/models/form/question.rb
  2. 8
      app/services/bulk_upload/lettings/year2024/row_parser.rb
  3. 8
      config/locales/en.yml
  4. 2
      spec/services/bulk_upload/lettings/year2023/row_parser_spec.rb
  5. 2
      spec/services/bulk_upload/lettings/year2024/row_parser_spec.rb

3
app/models/form/question.rb

@ -208,7 +208,8 @@ class Form::Question
end end
def unanswered_error_message def unanswered_error_message
I18n.t("validations.not_answered", question: error_display_label.downcase) question_text = error_display_label.presence || "this question"
I18n.t("validations.not_answered", question: question_text.downcase)
end end
def suffix_label(log) def suffix_label(log)

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

@ -44,7 +44,7 @@ class BulkUpload::Lettings::Year2024::RowParser
field_39: "If 'Other', what is the type of tenancy?", field_39: "If 'Other', what is the type of tenancy?",
field_40: "What is the length of the fixed-term tenancy to the nearest year?", field_40: "What is the length of the fixed-term tenancy to the nearest year?",
field_41: "Is this letting sheltered accommodation?", field_41: "Is this letting sheltered accommodation?",
field_15: "Has tenant seen the DLUHC privacy notice?", field_15: "Has tenant seen the MHCLG privacy notice?",
field_42: "What is the lead tenant's age?", field_42: "What is the lead tenant's age?",
field_43: "Which of these best describes the lead tenant's gender identity?", field_43: "Which of these best describes the lead tenant's gender identity?",
field_44: "Which of these best describes the lead tenant's ethnic background?", field_44: "Which of these best describes the lead tenant's ethnic background?",
@ -807,15 +807,13 @@ private
if setup_question?(question) if setup_question?(question)
fields.each do |field| fields.each do |field|
if errors.select { |e| fields.include?(e.attribute) }.none? if errors.select { |e| fields.include?(e.attribute) }.none?
question_text = question.error_display_label.presence || "this question" errors.add(field, question.unanswered_error_message, category: :setup) if field.present?
errors.add(field, I18n.t("validations.not_answered", question: question_text.downcase), category: :setup) if field.present?
end end
end end
else else
fields.each do |field| fields.each do |field|
unless errors.any? { |e| fields.include?(e.attribute) } unless errors.any? { |e| fields.include?(e.attribute) }
question_text = question.error_display_label.presence || "this question" errors.add(field, question.unanswered_error_message)
errors.add(field, I18n.t("validations.not_answered", question: question_text.downcase))
end end
end end
end end

8
config/locales/en.yml

@ -589,13 +589,13 @@ en:
declaration: declaration:
missing: missing:
pre_2024: "You must show the MHCLG privacy notice to the tenant before you can submit this log." pre_2024: "You must show the MHCLG privacy notice to the tenant before you can submit this log"
post_2024: "You must show or give access to the MHCLG privacy notice to the tenant before you can submit this log." post_2024: "You must show or give access to the MHCLG privacy notice to the tenant before you can submit this log"
privacynotice: privacynotice:
missing: missing:
pre_2024: "You must show the MHCLG privacy notice to the %{buyer_or_buyers} before you can submit this log." pre_2024: "You must show the MHCLG privacy notice to the %{buyer_or_buyers} before you can submit this log"
post_2024: "You must show or give access to the MHCLG privacy notice to the %{buyer_or_buyers} before you can submit this log." post_2024: "You must show or give access to the MHCLG privacy notice to the %{buyer_or_buyers} before you can submit this log"
scheme: scheme:
toggle_date: toggle_date:

2
spec/services/bulk_upload/lettings/year2023/row_parser_spec.rb

@ -686,7 +686,7 @@ RSpec.describe BulkUpload::Lettings::Year2023::RowParser do
it "cannot be nulled" do it "cannot be nulled" do
parser.valid? parser.valid?
expect(parser.errors[:field_45]).to eq(["You must show the MHCLG privacy notice to the tenant before you can submit this log."]) expect(parser.errors[:field_45]).to eq(["You must show the MHCLG privacy notice to the tenant before you can submit this log"])
end end
end end
end end

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

@ -747,7 +747,7 @@ RSpec.describe BulkUpload::Lettings::Year2024::RowParser do
it "cannot be nulled" do it "cannot be nulled" do
parser.valid? parser.valid?
expect(parser.errors[:field_15]).to eq(["You must answer tenant has seen the privacy notice"]) expect(parser.errors[:field_15]).to eq(["You must show or give access to the MHCLG privacy notice to the tenant before you can submit this log"])
end end
end end

Loading…
Cancel
Save