aboutsummaryrefslogtreecommitdiffstats
path: root/activestorage
diff options
context:
space:
mode:
Diffstat (limited to 'activestorage')
-rw-r--r--activestorage/app/jobs/active_storage/purge_job.rb2
-rw-r--r--activestorage/test/jobs/purge_job_test.rb10
2 files changed, 11 insertions, 1 deletions
diff --git a/activestorage/app/jobs/active_storage/purge_job.rb b/activestorage/app/jobs/active_storage/purge_job.rb
index fa15e0451d..b021b5f2d0 100644
--- a/activestorage/app/jobs/active_storage/purge_job.rb
+++ b/activestorage/app/jobs/active_storage/purge_job.rb
@@ -2,7 +2,7 @@
# Provides asynchronous purging of ActiveStorage::Blob records via ActiveStorage::Blob#purge_later.
class ActiveStorage::PurgeJob < ActiveStorage::BaseJob
- discard_on ActiveRecord::RecordNotFound
+ discard_on ActiveRecord::RecordNotFound, ActiveRecord::InvalidForeignKey
def perform(blob)
blob.purge
diff --git a/activestorage/test/jobs/purge_job_test.rb b/activestorage/test/jobs/purge_job_test.rb
index 251022a96f..ed4100b78d 100644
--- a/activestorage/test/jobs/purge_job_test.rb
+++ b/activestorage/test/jobs/purge_job_test.rb
@@ -24,4 +24,14 @@ class ActiveStorage::PurgeJobTest < ActiveJob::TestCase
end
end
end
+
+ test "ignores attached blob" do
+ User.create! name: "DHH", avatar: @blob
+
+ perform_enqueued_jobs do
+ assert_nothing_raised do
+ ActiveStorage::PurgeJob.perform_later @blob
+ end
+ end
+ end
end