From: Go MAEDA Date: Thu, 31 Oct 2019 13:07:14 +0000 (+0000) Subject: Don't try to generate thumbnails if convert command is not available (#32289). X-Git-Tag: 4.1.0~218 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=3ece374177451a37eb7c8a3d135aff60962cd387;p=redmine.git 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 --- diff --git a/app/models/attachment.rb b/app/models/attachment.rb index 8304d4dea..627c1a181 100644 --- a/app/models/attachment.rb +++ b/app/models/attachment.rb @@ -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 diff --git a/test/unit/attachment_test.rb b/test/unit/attachment_test.rb index fbbe71fbe..abe42587c 100644 --- a/test/unit/attachment_test.rb +++ b/test/unit/attachment_test.rb @@ -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