From c3b85f2b5036b25b87b9261ed1e14ccb5af4c8c3 Mon Sep 17 00:00:00 2001 From: Manny Dinssa <44172848+Dinssa@users.noreply.github.com> Date: Wed, 7 Aug 2024 13:26:40 +0100 Subject: [PATCH] CLDC-3411: Correct 24/25 bulk upload error messages on lettings and sales (#2553) --- app/models/form/question.rb | 3 ++- .../bulk_upload/lettings/year2024/row_parser.rb | 10 ++++------ config/locales/en.yml | 8 ++++---- .../models/form/lettings/questions/declaration_spec.rb | 4 ++-- .../models/form/sales/questions/privacy_notice_spec.rb | 8 ++++---- .../bulk_upload/lettings/year2023/row_parser_spec.rb | 2 +- .../bulk_upload/lettings/year2024/row_parser_spec.rb | 2 +- 7 files changed, 18 insertions(+), 19 deletions(-) diff --git a/app/models/form/question.rb b/app/models/form/question.rb index 960af8909..1fbced841 100644 --- a/app/models/form/question.rb +++ b/app/models/form/question.rb @@ -208,7 +208,8 @@ class Form::Question end 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 def suffix_label(log) diff --git a/app/services/bulk_upload/lettings/year2024/row_parser.rb b/app/services/bulk_upload/lettings/year2024/row_parser.rb index 2e54f5c3f..e523c11c4 100644 --- a/app/services/bulk_upload/lettings/year2024/row_parser.rb +++ b/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_40: "What is the length of the fixed-term tenancy to the nearest year?", 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_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?", @@ -806,16 +806,14 @@ private if setup_question?(question) fields.each do |field| - if errors.select { |e| fields.include?(e.attribute) }.none? - question_text = question.error_display_label.presence || "this question" - errors.add(field, I18n.t("validations.not_answered", question: question_text.downcase), category: :setup) if field.present? + if errors.select { |e| fields.include?(e.attribute) }.none? && field.present? + errors.add(field, question.unanswered_error_message, category: :setup) end end else fields.each do |field| unless errors.any? { |e| fields.include?(e.attribute) } - question_text = question.error_display_label.presence || "this question" - errors.add(field, I18n.t("validations.not_answered", question: question_text.downcase)) + errors.add(field, question.unanswered_error_message) end end end diff --git a/config/locales/en.yml b/config/locales/en.yml index b6ba761f2..4dfe72872 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -589,13 +589,13 @@ en: declaration: missing: - 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." + 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" privacynotice: missing: - 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." + 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" scheme: toggle_date: diff --git a/spec/models/form/lettings/questions/declaration_spec.rb b/spec/models/form/lettings/questions/declaration_spec.rb index ab9bcebef..7e4d47249 100644 --- a/spec/models/form/lettings/questions/declaration_spec.rb +++ b/spec/models/form/lettings/questions/declaration_spec.rb @@ -63,7 +63,7 @@ RSpec.describe Form::Lettings::Questions::Declaration, type: :model do end it "returns correct unanswered_error_message" do - expect(question.unanswered_error_message).to eq("You must show the MHCLG privacy notice to the tenant before you can submit this log.") + expect(question.unanswered_error_message).to eq("You must show the MHCLG privacy notice to the tenant before you can submit this log") end end @@ -87,7 +87,7 @@ RSpec.describe Form::Lettings::Questions::Declaration, type: :model do end it "returns correct unanswered_error_message" do - expect(question.unanswered_error_message).to eq("You must show or give access to the MHCLG privacy notice to the tenant before you can submit this log.") + expect(question.unanswered_error_message).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 diff --git a/spec/models/form/sales/questions/privacy_notice_spec.rb b/spec/models/form/sales/questions/privacy_notice_spec.rb index 4be918c5c..bbaabb6a5 100644 --- a/spec/models/form/sales/questions/privacy_notice_spec.rb +++ b/spec/models/form/sales/questions/privacy_notice_spec.rb @@ -60,7 +60,7 @@ RSpec.describe Form::Sales::Questions::PrivacyNotice, type: :model do end it "returns correct unanswered_error_message" do - expect(question.unanswered_error_message).to eq("You must show the MHCLG privacy notice to the buyer before you can submit this log.") + expect(question.unanswered_error_message).to eq("You must show the MHCLG privacy notice to the buyer before you can submit this log") end end @@ -78,7 +78,7 @@ RSpec.describe Form::Sales::Questions::PrivacyNotice, type: :model do end it "returns correct unanswered_error_message" do - expect(question.unanswered_error_message).to eq("You must show the MHCLG privacy notice to the buyers before you can submit this log.") + expect(question.unanswered_error_message).to eq("You must show the MHCLG privacy notice to the buyers before you can submit this log") end end end @@ -100,7 +100,7 @@ RSpec.describe Form::Sales::Questions::PrivacyNotice, type: :model do end it "returns correct unanswered_error_message" do - expect(question.unanswered_error_message).to eq("You must show or give access to the MHCLG privacy notice to the buyer before you can submit this log.") + expect(question.unanswered_error_message).to eq("You must show or give access to the MHCLG privacy notice to the buyer before you can submit this log") end end @@ -118,7 +118,7 @@ RSpec.describe Form::Sales::Questions::PrivacyNotice, type: :model do end it "returns correct unanswered_error_message" do - expect(question.unanswered_error_message).to eq("You must show or give access to the MHCLG privacy notice to the buyers before you can submit this log.") + expect(question.unanswered_error_message).to eq("You must show or give access to the MHCLG privacy notice to the buyers before you can submit this log") end end end diff --git a/spec/services/bulk_upload/lettings/year2023/row_parser_spec.rb b/spec/services/bulk_upload/lettings/year2023/row_parser_spec.rb index a8cfd0a79..e38396328 100644 --- a/spec/services/bulk_upload/lettings/year2023/row_parser_spec.rb +++ b/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 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 diff --git a/spec/services/bulk_upload/lettings/year2024/row_parser_spec.rb b/spec/services/bulk_upload/lettings/year2024/row_parser_spec.rb index 7cae5eeae..405bb292d 100644 --- a/spec/services/bulk_upload/lettings/year2024/row_parser_spec.rb +++ b/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 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