diff options
-rw-r--r-- | activestorage/test/models/blob_test.rb | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/activestorage/test/models/blob_test.rb b/activestorage/test/models/blob_test.rb index a0e207642a..c2e7aae13a 100644 --- a/activestorage/test/models/blob_test.rb +++ b/activestorage/test/models/blob_test.rb @@ -174,6 +174,14 @@ class ActiveStorage::BlobTest < ActiveSupport::TestCase assert_not ActiveStorage::Blob.service.exist?(variant.key) end + test "purge fails when attachments exist" do + create_blob.tap do |blob| + User.create! name: "DHH", avatar: blob + assert_raises(ActiveRecord::InvalidForeignKey) { blob.purge } + assert ActiveStorage::Blob.service.exist?(blob.key) + end + end + private def expected_url_for(blob, disposition: :inline, filename: nil) filename ||= blob.filename |