1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Test that ActiveStorage::Blob#purge fails when attachments exist

This commit is contained in:
George Claghorn 2018-07-20 10:28:14 -04:00
parent 2ae3a29508
commit 562ec3dcd1

View file

@ -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