diff --git a/app/services/bulk_upload/processor.rb b/app/services/bulk_upload/processor.rb index 3ba6fb4d8..af9d86dfb 100644 --- a/app/services/bulk_upload/processor.rb +++ b/app/services/bulk_upload/processor.rb @@ -34,6 +34,8 @@ class BulkUpload::Processor end def approve + return if bulk_upload.processed? + download create_logs ensure diff --git a/spec/services/bulk_upload/processor_spec.rb b/spec/services/bulk_upload/processor_spec.rb index edd049cd8..0c50ee8fd 100644 --- a/spec/services/bulk_upload/processor_spec.rb +++ b/spec/services/bulk_upload/processor_spec.rb @@ -243,4 +243,26 @@ RSpec.describe BulkUpload::Processor do end end end + + describe "#approve" do + let(:mock_creator) do + instance_double( + BulkUpload::Lettings::LogCreator, + call: nil, + path: nil, + ) + end + + context "when already processed" do + let(:bulk_upload) { create(:bulk_upload, :lettings, processed: true) } + + it "does not create logs again" do + allow(BulkUpload::Lettings::LogCreator).to receive(:new).with(bulk_upload:, path: nil).and_return(mock_creator) + + processor.approve + + expect(mock_creator).not_to have_received(:call) + end + end + end end