From 66a0d323e9fbed7ebe9125dae9c1244fddf069d9 Mon Sep 17 00:00:00 2001 From: Kat Date: Thu, 11 May 2023 15:35:50 +0100 Subject: [PATCH] Correctly set the log status, remove redundant confirm_soft_validations --- app/models/bulk_upload.rb | 2 -- app/services/bulk_upload/lettings/log_creator.rb | 3 +-- app/services/bulk_upload/processor.rb | 5 ++--- app/services/bulk_upload/sales/log_creator.rb | 3 +-- spec/services/bulk_upload/lettings/log_creator_spec.rb | 9 +++++++++ spec/services/bulk_upload/processor_spec.rb | 8 ++++---- 6 files changed, 17 insertions(+), 13 deletions(-) diff --git a/app/models/bulk_upload.rb b/app/models/bulk_upload.rb index 5e6f1f9e5..c41f8f244 100644 --- a/app/models/bulk_upload.rb +++ b/app/models/bulk_upload.rb @@ -74,8 +74,6 @@ class BulkUpload < ApplicationRecord def unpend_and_confirm_soft_validations logs.find_each do |log| - log.skip_update_status = true - log.status = log.status_cache log.retirement_value_check = 0 log.pregnancy_value_check = 0 log.major_repairs_date_value_check = 0 diff --git a/app/services/bulk_upload/lettings/log_creator.rb b/app/services/bulk_upload/lettings/log_creator.rb index 721ccdcd6..8d3a6cbd7 100644 --- a/app/services/bulk_upload/lettings/log_creator.rb +++ b/app/services/bulk_upload/lettings/log_creator.rb @@ -1,10 +1,9 @@ class BulkUpload::Lettings::LogCreator attr_reader :bulk_upload, :path - def initialize(bulk_upload:, path:, confirm_soft_validations: false) + def initialize(bulk_upload:, path:) @bulk_upload = bulk_upload @path = path - @confirm_soft_validations = confirm_soft_validations end def call diff --git a/app/services/bulk_upload/processor.rb b/app/services/bulk_upload/processor.rb index 6b097c067..b268aa65c 100644 --- a/app/services/bulk_upload/processor.rb +++ b/app/services/bulk_upload/processor.rb @@ -17,7 +17,7 @@ class BulkUpload::Processor elsif validator.create_logs? create_logs - + if validator.soft_validation_errors_only? send_check_soft_validations_mail elsif created_logs_but_incompleted? @@ -94,11 +94,10 @@ private bulk_upload.user end - def create_logs(confirm_soft_validations: false) + def create_logs log_creator_class.new( bulk_upload:, path: downloader.path, - confirm_soft_validations:, ).call end diff --git a/app/services/bulk_upload/sales/log_creator.rb b/app/services/bulk_upload/sales/log_creator.rb index 1267a20ee..69ef637fa 100644 --- a/app/services/bulk_upload/sales/log_creator.rb +++ b/app/services/bulk_upload/sales/log_creator.rb @@ -1,10 +1,9 @@ class BulkUpload::Sales::LogCreator attr_reader :bulk_upload, :path - def initialize(bulk_upload:, path:, confirm_soft_validations: false) + def initialize(bulk_upload:, path:) @bulk_upload = bulk_upload @path = path - @confirm_soft_validations = confirm_soft_validations end def call diff --git a/spec/services/bulk_upload/lettings/log_creator_spec.rb b/spec/services/bulk_upload/lettings/log_creator_spec.rb index b1b9213d0..87ac6e320 100644 --- a/spec/services/bulk_upload/lettings/log_creator_spec.rb +++ b/spec/services/bulk_upload/lettings/log_creator_spec.rb @@ -164,6 +164,15 @@ RSpec.describe BulkUpload::Lettings::LogCreator do service.call expect(LettingsLog.last.status).to eql("pending") end + + it "does not set unanswered soft validations" do + service.call + + log = LettingsLog.last + expect(log.age1).to be(22) + expect(log.ecstat1).to be(5) + expect(log.retirement_value_check).to be(nil) + end end context "when valid csv with existing log" do diff --git a/spec/services/bulk_upload/processor_spec.rb b/spec/services/bulk_upload/processor_spec.rb index 2adbd9616..1549bee52 100644 --- a/spec/services/bulk_upload/processor_spec.rb +++ b/spec/services/bulk_upload/processor_spec.rb @@ -235,14 +235,14 @@ RSpec.describe BulkUpload::Processor do expect(mail_double).to have_received(:deliver_later) end - it "calls log creator without the confirm_soft_validations option" do + it "calls log creator" do log_creator_double = instance_double(BulkUpload::Lettings::LogCreator, call: nil) allow(BulkUpload::Lettings::LogCreator).to receive(:new).and_return(log_creator_double) processor.call - expect(BulkUpload::Lettings::LogCreator).to have_received(:new).with(bulk_upload:, path:, confirm_soft_validations: false) + expect(BulkUpload::Lettings::LogCreator).to have_received(:new).with(bulk_upload:, path:) end end @@ -313,14 +313,14 @@ RSpec.describe BulkUpload::Processor do expect(mail_double).to have_received(:deliver_later) end - it "calls log creator with the confirm_soft_validations option" do + it "calls log creator" do log_creator_double = instance_double(BulkUpload::Lettings::LogCreator, call: nil) allow(BulkUpload::Lettings::LogCreator).to receive(:new).and_return(log_creator_double) processor.call - expect(BulkUpload::Lettings::LogCreator).to have_received(:new).with(bulk_upload:, path:, confirm_soft_validations: true) + expect(BulkUpload::Lettings::LogCreator).to have_received(:new).with(bulk_upload:, path:) end end