From f34706a0cf2a01f5d5090b447012aa26fad30a21 Mon Sep 17 00:00:00 2001 From: Kat Date: Mon, 22 May 2023 09:44:19 +0100 Subject: [PATCH] Add error as part of validating radio options --- .../bulk_upload/sales/year2022/row_parser.rb | 12 ++---------- .../bulk_upload/sales/year2023/row_parser.rb | 3 ++- 2 files changed, 4 insertions(+), 11 deletions(-) diff --git a/app/services/bulk_upload/sales/year2022/row_parser.rb b/app/services/bulk_upload/sales/year2022/row_parser.rb index 65d8a8085..36831faa6 100644 --- a/app/services/bulk_upload/sales/year2022/row_parser.rb +++ b/app/services/bulk_upload/sales/year2022/row_parser.rb @@ -287,7 +287,6 @@ class BulkUpload::Sales::Year2022::RowParser validate :validate_relevant_collection_window, on: :after_log validate :validate_incomplete_soft_validations, on: :after_log validate :validate_if_log_already_exists, on: :after_log, if: -> { FeatureToggle.bulk_upload_duplicate_log_check_enabled? } - validate :validate_shared_ownership_type, on: :after_log, if: :shared_ownership? def self.question_for_field(field) QUESTIONS[field] @@ -967,7 +966,8 @@ private if setup_question?(question) fields.each do |field| - if errors[field].present? + if errors[field].blank? + block_log_creation! errors.add(field, I18n.t("validations.invalid_option", question: QUESTIONS[field]), category: :setup) end end @@ -1029,12 +1029,4 @@ private errors.add(:field_24, "Buyer 1 cannot be a child under 16") end end - - def validate_shared_ownership_type - if sale_type == 32 - block_log_creation! - - errors.add(:field_57, I18n.t("validations.invalid_option", question: "shared ownership type"), category: :setup) - end - end end diff --git a/app/services/bulk_upload/sales/year2023/row_parser.rb b/app/services/bulk_upload/sales/year2023/row_parser.rb index 1475269e0..1e1bfbc0c 100644 --- a/app/services/bulk_upload/sales/year2023/row_parser.rb +++ b/app/services/bulk_upload/sales/year2023/row_parser.rb @@ -1163,7 +1163,8 @@ private if setup_question?(question) fields.each do |field| - if errors[field].present? + if errors[field].blank? + block_log_creation! errors.add(field, I18n.t("validations.invalid_option", question: QUESTIONS[field]), category: :setup) end end