Skip to content

Commit

Permalink
Use sleep in test only, to not get in the way of app execution
Browse files Browse the repository at this point in the history
  • Loading branch information
texpert committed Jul 19, 2024
1 parent e89ccd4 commit 2ed4b34
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion config/initializers/custom_initializers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,16 @@
eval(File.read(f)) if File.exist?(f)
end

# This can be overridden in the app initializer to wrap the sleep and delete_file in an async job
# This block can be overridden in the app initializer to wrap the sleep and delete_file in an async job,
# something like this:
#
# CamaleonDeleteFileJob.set(wait: temporal_time).perform_later(file_key)
# # put this in app/jobs/camaleon_delete_file_job.rb:
# include CamaleonCms::UploaderHelper
# cama_uploader.delete_file(file_key)
CamaleonCmsUploader.delete_block do |settings, cama_uploader, file_key|
next unless Rails.env.test?

sleep(settings[:temporal_time])
cama_uploader.delete_file(file_key)
end
Expand Down

0 comments on commit 2ed4b34

Please sign in to comment.