]> source.dussan.org Git - redmine.git/commitdiff
Don't try to generate thumbnails if convert command is not available (#32289).
authorGo MAEDA <maeda@farend.jp>
Thu, 31 Oct 2019 13:07:14 +0000 (13:07 +0000)
committerGo MAEDA <maeda@farend.jp>
Thu, 31 Oct 2019 13:07:14 +0000 (13:07 +0000)
Patch by Go MAEDA.

git-svn-id: http://svn.redmine.org/redmine/trunk@18885 e93f8b46-1217-0410-a6f0-8f06a7374b81

app/models/attachment.rb
test/unit/attachment_test.rb

index 8304d4dea6332426d01977f5d3dccbab7d9a59ec..627c1a1811d2e5d7363fc01eaff29cc83c10a95b 100644 (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
index fbbe71fbecd77856105ad792653181c53dc7429e..abe42587cc7eeed84081ca821fd5edbb0a94004e 100644 (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