Browse Source

delete existing errors before bulk upload run

pull/1674/head
Phil Lee 3 years ago
parent
commit
0129b27c38
  1. 6
      app/services/bulk_upload/processor.rb
  2. 10
      spec/services/bulk_upload/processor_spec.rb

6
app/services/bulk_upload/processor.rb

@ -6,6 +6,8 @@ class BulkUpload::Processor
end end
def call def call
destroy_any_existing_errors_from_prior_run
download download
return send_failure_mail(errors: validator.errors.full_messages) if validator.invalid? return send_failure_mail(errors: validator.errors.full_messages) if validator.invalid?
@ -46,6 +48,10 @@ class BulkUpload::Processor
private private
def destroy_any_existing_errors_from_prior_run
bulk_upload.bulk_upload_errors.destroy_all
end
def send_how_to_fix_upload_mail def send_how_to_fix_upload_mail
BulkUploadMailer BulkUploadMailer
.send_how_to_fix_upload_mail(bulk_upload:) .send_how_to_fix_upload_mail(bulk_upload:)

10
spec/services/bulk_upload/processor_spec.rb

@ -8,6 +8,16 @@ RSpec.describe BulkUpload::Processor do
let(:owning_org) { create(:organisation, old_visible_id: 123) } let(:owning_org) { create(:organisation, old_visible_id: 123) }
describe "#call" do describe "#call" do
context "when errors exist from prior job run" do
let!(:existing_error) { create(:bulk_upload_error, bulk_upload:) }
it "destroys existing errors" do
processor.call
expect { existing_error.reload }.to raise_error(ActiveRecord::RecordNotFound)
end
end
context "when the bulk upload itself is not considered valid" do context "when the bulk upload itself is not considered valid" do
let(:mock_downloader) do let(:mock_downloader) do
instance_double( instance_double(

Loading…
Cancel
Save