diff options
author | Go MAEDA <maeda@farend.jp> | 2024-05-27 14:26:16 +0000 |
---|---|---|
committer | Go MAEDA <maeda@farend.jp> | 2024-05-27 14:26:16 +0000 |
commit | 6a4abab8ce00b5b0cb6e0a161bfedf3366393308 (patch) | |
tree | 2436e454cdde5085aac266f9112aa429c2973681 /test | |
parent | a4e7d34cb7582910a2c8f512c31220873404cbaa (diff) | |
download | redmine-6a4abab8ce00b5b0cb6e0a161bfedf3366393308.tar.gz redmine-6a4abab8ce00b5b0cb6e0a161bfedf3366393308.zip |
Add timeout for thumbnail generation process (#37530).
Patch by Go MAEDA (@maeda).
git-svn-id: https://svn.redmine.org/redmine/trunk@22847 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'test')
-rw-r--r-- | test/unit/attachment_test.rb | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/test/unit/attachment_test.rb b/test/unit/attachment_test.rb index 2e37672ab..b88350fba 100644 --- a/test/unit/attachment_test.rb +++ b/test/unit/attachment_test.rb @@ -626,6 +626,25 @@ class AttachmentTest < ActiveSupport::TestCase ensure set_tmp_attachments_directory end + + def test_thumbnail_should_timeout + dummy_pid = 37530 + Process.stubs(:spawn).returns(dummy_pid) + Process.stubs(:wait2).raises(Timeout::Error) + Process.stubs(:kill).returns(1) + Process.stubs(:wait).returns(dummy_pid) + Rails.logger.expects(:error).with(regexp_matches(/Creating thumbnail timed out/)) + + set_fixtures_attachments_directory + Attachment.clear_thumbnails + + attachment = Attachment.find(16) + thumbnail = attachment.thumbnail + + assert_nil thumbnail + ensure + set_tmp_attachments_directory + end else puts '(ImageMagick convert not available)' end |