Deletes thumbnails when the attachment diskfile is deleted (#30177).

Patch by Jens Krämer.


git-svn-id: http://svn.redmine.org/redmine/trunk@17736 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Go MAEDA
2018-12-15 02:58:45 +00:00
parent bda0de0044
commit cccd14ae5c
2 changed files with 24 additions and 1 deletions

View File

@@ -457,6 +457,21 @@ class AttachmentTest < ActiveSupport::TestCase
assert_equal a_thumb, b_thumb
end
def test_destroy_should_destroy_thumbnails
a = Attachment.create!(
:container => Issue.find(1),
:file => uploaded_test_file("2010/11/101123161450_testfile_1.png", "image/png"),
:author => User.find(1)
)
diskfile = a.diskfile
thumbnail = a.thumbnail
assert File.exist?(diskfile)
assert File.exist?(thumbnail)
assert a.destroy
refute File.exist?(diskfile)
refute File.exist?(thumbnail)
end
def test_thumbnail_should_return_nil_if_generation_fails
Redmine::Thumbnail.expects(:generate).raises(SystemCallError, 'Something went wrong')
set_fixtures_attachments_directory