From b6bbedf1a8f12fdc8814acb547a36640814f22ca Mon Sep 17 00:00:00 2001 From: Jeremy Prevost Date: Thu, 15 Feb 2018 16:30:15 -0500 Subject: ActiveStorage file cleanup in Integration Tests Documents ActiveStorage file cleanup in Integration Tests which is similar but slightly different than the existing docs for System Tests. --- guides/source/active_storage_overview.md | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'guides') diff --git a/guides/source/active_storage_overview.md b/guides/source/active_storage_overview.md index 97c56dfd93..c72a38b1de 100644 --- a/guides/source/active_storage_overview.md +++ b/guides/source/active_storage_overview.md @@ -556,6 +556,30 @@ config.active_job.queue_adapter = :inline config.active_storage.service = :local_test ``` +Discarding Files Stored During Integration Tests +------------------------------------------- + +Similarly to System Tests, files uploaded during Integration Tests will not be +automatically cleaned up. If you want to clear the files, you can do it in an +`after_teardown` callback. Doing it here ensures that all connections created +during the test are complete and you won't receive an error from Active Storage +saying it can't find a file. + +```ruby +module ActionDispatch + class IntegrationTest + def remove_uploaded_files + FileUtils.rm_rf(Rails.root.join('tmp', 'storage')) + end + + def after_teardown + super + remove_uploaded_files + end + end +end +``` + Implementing Support for Other Cloud Services --------------------------------------------- -- cgit v1.2.3