diff --git a/app/services/bulk_upload/lettings/year2024/row_parser.rb b/app/services/bulk_upload/lettings/year2024/row_parser.rb index 1c8076263..cbb7a1087 100644 --- a/app/services/bulk_upload/lettings/year2024/row_parser.rb +++ b/app/services/bulk_upload/lettings/year2024/row_parser.rb @@ -809,7 +809,7 @@ private if managing_organisation.nil? block_log_creation! - if errors[:field_2].blank? + if field_2.present? && errors[:field_2].blank? errors.add(:field_2, "The managing organisation code is incorrect", category: :setup) end end @@ -818,7 +818,7 @@ private def validate_managing_org_data_given if field_2.blank? block_log_creation! - errors.add(:field_2, "The managing organisation code is incorrect", category: :setup) + errors.add(:field_2, I18n.t("validations.not_answered", question: "managing organisation"), category: :setup) end end @@ -836,7 +836,7 @@ private if owning_organisation.nil? block_log_creation! - if errors[:field_1].blank? + if field_1.present? && errors[:field_1].blank? errors.add(:field_1, "The owning organisation code is incorrect", category: :setup) end end diff --git a/app/services/bulk_upload/sales/year2024/row_parser.rb b/app/services/bulk_upload/sales/year2024/row_parser.rb index 0dc00be36..ed8763baf 100644 --- a/app/services/bulk_upload/sales/year2024/row_parser.rb +++ b/app/services/bulk_upload/sales/year2024/row_parser.rb @@ -1260,7 +1260,7 @@ private block_log_creation! if errors[:field_1].blank? - errors.add(:field_1, "The owning organisation code is incorrect", category: :setup) + errors.add(:field_1, I18n.t("validations.not_answered", question: "owning organisation"), category: :setup) end end end @@ -1269,7 +1269,7 @@ private if owning_organisation.nil? block_log_creation! - if errors[:field_1].blank? + if field_1.present? && errors[:field_1].blank? errors.add(:field_1, "The owning organisation code is incorrect", category: :setup) end end diff --git a/spec/services/bulk_upload/sales/year2024/row_parser_spec.rb b/spec/services/bulk_upload/sales/year2024/row_parser_spec.rb index 130af4135..db34d9c0c 100644 --- a/spec/services/bulk_upload/sales/year2024/row_parser_spec.rb +++ b/spec/services/bulk_upload/sales/year2024/row_parser_spec.rb @@ -438,7 +438,7 @@ RSpec.describe BulkUpload::Sales::Year2024::RowParser do let(:attributes) { { bulk_upload:, field_1: "donotexist" } } it "is not permitted as a setup error" do - expect(parser.errors.where(:field_1, category: :setup).map(&:message)).to eql(["You must answer owning organisation"]) + expect(parser.errors.where(:field_1, category: :setup).map(&:message)).to eql(["The owning organisation code is incorrect"]) end it "blocks log creation" do