Browse Source

CLDC-3411 correct 24 25 bulk upload error messages on lettings and sales (#2556)

* Update error messages and sales parser
pull/2557/head
Manny Dinssa 6 months ago committed by GitHub
parent
commit
1da04df30f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 4
      app/services/bulk_upload/sales/year2024/row_parser.rb
  2. 4
      config/locales/en.yml
  3. 2
      spec/models/form/lettings/questions/declaration_spec.rb
  4. 4
      spec/models/form/sales/questions/privacy_notice_spec.rb
  5. 2
      spec/services/bulk_upload/lettings/year2024/row_parser_spec.rb
  6. 11
      spec/services/bulk_upload/sales/year2024/row_parser_spec.rb

4
app/services/bulk_upload/sales/year2024/row_parser.rb

@ -1364,13 +1364,13 @@ private
if setup_question?(question) if setup_question?(question)
fields.each do |field| fields.each do |field|
unless errors.any? { |e| fields.include?(e.attribute) } unless errors.any? { |e| fields.include?(e.attribute) }
errors.add(field, I18n.t("validations.not_answered", question: question.error_display_label&.downcase), category: :setup) errors.add(field, question.unanswered_error_message, category: :setup)
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) }
errors.add(field, I18n.t("validations.not_answered", question: question.error_display_label&.downcase)) errors.add(field, question.unanswered_error_message)
end end
end end
end end

4
config/locales/en.yml

@ -590,12 +590,12 @@ 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 the tenant access to the MHCLG privacy notice 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 the %{buyer_or_buyers} access to the MHCLG privacy notice before you can submit this log"
scheme: scheme:
toggle_date: toggle_date:

2
spec/models/form/lettings/questions/declaration_spec.rb

@ -87,7 +87,7 @@ RSpec.describe Form::Lettings::Questions::Declaration, type: :model do
end end
it "returns correct unanswered_error_message" do 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 the tenant access to the MHCLG privacy notice before you can submit this log")
end end
end end
end end

4
spec/models/form/sales/questions/privacy_notice_spec.rb

@ -100,7 +100,7 @@ RSpec.describe Form::Sales::Questions::PrivacyNotice, type: :model do
end end
it "returns correct unanswered_error_message" do 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 the buyer access to the MHCLG privacy notice before you can submit this log")
end end
end end
@ -118,7 +118,7 @@ RSpec.describe Form::Sales::Questions::PrivacyNotice, type: :model do
end end
it "returns correct unanswered_error_message" do 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 the buyers access to the MHCLG privacy notice 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 show or give access to the MHCLG privacy notice to the tenant before you can submit this log"]) expect(parser.errors[:field_15]).to eq(["You must show or give the tenant access to the MHCLG privacy notice before you can submit this log"])
end end
end end

11
spec/services/bulk_upload/sales/year2024/row_parser_spec.rb

@ -1042,12 +1042,21 @@ RSpec.describe BulkUpload::Sales::Year2024::RowParser do
describe "#field_18" do # data protection describe "#field_18" do # data protection
let(:attributes) { setup_section_params.merge({ field_18: nil }) } let(:attributes) { setup_section_params.merge({ field_18: nil }) }
before do
parser.valid?
end
context "when not answered" do context "when not answered" do
it "returns a setup error" do it "returns a setup error" do
parser.valid?
expect(parser.errors.where(:field_18, category: :setup)).to be_present expect(parser.errors.where(:field_18, category: :setup)).to be_present
end end
end end
context "when the privacy notice is not accepted" do
it "cannot be nulled" do
expect(parser.errors[:field_18]).to eq(["You must show or give the buyer access to the MHCLG privacy notice before you can submit this log"])
end
end
end end
[ [

Loading…
Cancel
Save