diff options
author | Jasper Martin <jaspervanbrianmartin@gmail.com> | 2018-07-26 21:24:31 +0800 |
---|---|---|
committer | George Claghorn <george.claghorn@gmail.com> | 2018-07-26 09:24:31 -0400 |
commit | 934fccd5223ae41f3f1cc7d548af509302f64828 (patch) | |
tree | b4ed89df2087796fa7cbeb139803efda693ae154 /activestorage/test/models/blob_test.rb | |
parent | 8a5fe2bcded1468934f060666a69dcd7d1fac9ae (diff) | |
download | rails-934fccd5223ae41f3f1cc7d548af509302f64828.tar.gz rails-934fccd5223ae41f3f1cc7d548af509302f64828.tar.bz2 rails-934fccd5223ae41f3f1cc7d548af509302f64828.zip |
Ignore ActiveRecord::InvalidForeignKey in ActiveStorage::Blob#purge
Do nothing instead of raising an error when it’s called on an attached blob.
Diffstat (limited to 'activestorage/test/models/blob_test.rb')
-rw-r--r-- | activestorage/test/models/blob_test.rb | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/activestorage/test/models/blob_test.rb b/activestorage/test/models/blob_test.rb index c2e7aae13a..88c106a08b 100644 --- a/activestorage/test/models/blob_test.rb +++ b/activestorage/test/models/blob_test.rb @@ -174,10 +174,10 @@ class ActiveStorage::BlobTest < ActiveSupport::TestCase assert_not ActiveStorage::Blob.service.exist?(variant.key) end - test "purge fails when attachments exist" do + test "purge does nothing when attachments exist" do create_blob.tap do |blob| User.create! name: "DHH", avatar: blob - assert_raises(ActiveRecord::InvalidForeignKey) { blob.purge } + assert_no_difference(-> { ActiveStorage::Blob.count }) { blob.purge } assert ActiveStorage::Blob.service.exist?(blob.key) end end |