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:
parent
2ae3a29508
commit
562ec3dcd1
1 changed files with 8 additions and 0 deletions
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue