Browse Source

prevent approve being called multiple times

bulk-upload-resume
Phil Lee 2 years ago
parent
commit
eb5258b0c0
  1. 2
      app/services/bulk_upload/processor.rb
  2. 22
      spec/services/bulk_upload/processor_spec.rb

2
app/services/bulk_upload/processor.rb

@ -34,6 +34,8 @@ class BulkUpload::Processor
end end
def approve def approve
return if bulk_upload.processed?
download download
create_logs create_logs
ensure ensure

22
spec/services/bulk_upload/processor_spec.rb

@ -243,4 +243,26 @@ RSpec.describe BulkUpload::Processor do
end end
end 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 end

Loading…
Cancel
Save