Skip to content

Commit

Permalink
HYC-1950 Remove File Delete in Dimensions Ingest (Follow Up) (#1114)
Browse files Browse the repository at this point in the history
* remove file delete in process publication

* remove test for checking file removal
  • Loading branch information
davidcam-src authored Aug 13, 2024
1 parent 90f53c2 commit ba95ac7
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 25 deletions.
1 change: 0 additions & 1 deletion app/services/tasks/dimensions_ingest_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ def process_publication(publication)
if pdf_path
pdf_file = attach_pdf_to_work(article, pdf_path, @depositor)
pdf_file.update(permissions_attributes: group_permissions(@admin_set))
File.delete(pdf_path) if File.exist?(pdf_path)
end
article
end
Expand Down
24 changes: 0 additions & 24 deletions spec/services/tasks/dimensions_ingest_service_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -92,30 +92,6 @@
expect(fs.visibility).to eq(processed_publication.visibility)
expect(fs.parent).to eq(processed_publication)
end

it 'deletes the PDF file after processing' do
publication = test_publications.first
fixed_time = Time.now
formatted_time = fixed_time.strftime('%Y%m%d%H%M%S%L')
test_file_path = "#{ENV['TEMP_STORAGE']}/downloaded_pdf_#{formatted_time}.pdf"

# Mock the time to control file naming
allow(Time).to receive(:now).and_return(fixed_time)

allow(File).to receive(:open).and_call_original
allow(File).to receive(:delete).and_call_original
allow(File).to receive(:exist?).and_call_original
allow(File).to receive(:join).and_call_original

expect {
service.process_publication(publication)
}.to change { Article.count }.by(1)

expect(File).to have_received(:join).with(ENV['TEMP_STORAGE'], "downloaded_pdf_#{formatted_time}.pdf")
expect(File).to have_received(:open).with(test_file_path).at_least(:once)
expect(File).to have_received(:delete).with(test_file_path)
expect(File.exist?(test_file_path)).to be false
end
end
context 'when the publication does not have a PDF' do
it 'creates article and handles workflows' do
Expand Down

0 comments on commit ba95ac7

Please sign in to comment.