Don't try to generate thumbnails if convert command is not available (#32289).

Patch by Go MAEDA.


git-svn-id: http://svn.redmine.org/redmine/trunk@18885 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Go MAEDA
2019-10-31 13:07:14 +00:00
parent 5d2960d36f
commit 3ece374177
2 changed files with 9 additions and 2 deletions

View File

@@ -201,7 +201,9 @@ class Attachment < ActiveRecord::Base
end
def thumbnailable?
image? || (is_pdf? && Redmine::Thumbnail.gs_available?)
Redmine::Thumbnail.convert_available? && (
image? || (is_pdf? && Redmine::Thumbnail.gs_available?)
)
end
# Returns the full path the attachment thumbnail, or nil

View File

@@ -420,7 +420,12 @@ class AttachmentTest < ActiveSupport::TestCase
assert_equal true, Attachment.new(:filename => 'test.jpg').thumbnailable?
end
def test_thumbnailable_should_be_true_for_non_images
def test_thumbnailable_should_be_false_for_images_if_convert_is_unavailable
Redmine::Thumbnail.stubs(:convert_available?).returns(false)
assert_equal false, Attachment.new(:filename => 'test.jpg').thumbnailable?
end
def test_thumbnailable_should_be_false_for_non_images
assert_equal false, Attachment.new(:filename => 'test.txt').thumbnailable?
end