diff options
author | George Claghorn <george@basecamp.com> | 2018-07-20 10:28:14 -0400 |
---|---|---|
committer | George Claghorn <george@basecamp.com> | 2018-07-20 10:28:14 -0400 |
commit | 562ec3dcd1a353eb5c20f130acc71c0707f7ff50 (patch) | |
tree | e56fea06e3a1110383048a953a3bd8e908c15310 /activestorage | |
parent | 2ae3a29508e2a5daab6dd3eea3e10e40df6fd945 (diff) | |
download | rails-562ec3dcd1a353eb5c20f130acc71c0707f7ff50.tar.gz rails-562ec3dcd1a353eb5c20f130acc71c0707f7ff50.tar.bz2 rails-562ec3dcd1a353eb5c20f130acc71c0707f7ff50.zip |
Test that ActiveStorage::Blob#purge fails when attachments exist
Diffstat (limited to 'activestorage')
-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 |