diff options
author | George Claghorn <george@basecamp.com> | 2018-07-20 11:18:37 -0400 |
---|---|---|
committer | George Claghorn <george@basecamp.com> | 2018-07-20 11:18:37 -0400 |
commit | 6c45b04a7399bb629bf17319dc3519a061d4d7a0 (patch) | |
tree | b4944b914623620a973389508de600c8f20ac743 /activestorage | |
parent | 562ec3dcd1a353eb5c20f130acc71c0707f7ff50 (diff) | |
download | rails-6c45b04a7399bb629bf17319dc3519a061d4d7a0.tar.gz rails-6c45b04a7399bb629bf17319dc3519a061d4d7a0.tar.bz2 rails-6c45b04a7399bb629bf17319dc3519a061d4d7a0.zip |
Discard ActiveStorage::PurgeJobs on ActiveRecord::InvalidForeignKey
Diffstat (limited to 'activestorage')
-rw-r--r-- | activestorage/app/jobs/active_storage/purge_job.rb | 2 | ||||
-rw-r--r-- | activestorage/test/jobs/purge_job_test.rb | 10 |
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 |