Browse Source

Test for r18158 (#22481).

Patch by Go MAEDA.


git-svn-id: http://svn.redmine.org/redmine/trunk@18159 e93f8b46-1217-0410-a6f0-8f06a7374b81
tags/4.1.0
Go MAEDA 5 years ago
parent
commit
96b6bdfb77

+ 14
- 0
test/fixtures/attachments.yml View File

@@ -295,3 +295,17 @@ attachments_022:
author_id: 1
description: unknown type
content_type:
attachments_023:
created_on: 2019-05-11 14:18:19 +09:00
content_type: application/pdf
container_type: WikiPage
container_id: 1
downloads: 0
disk_filename: 190511141819_ecookbook-gantt.pdf
disk_directory: "2019/05"
digest: da9c52e79d9eee7d47b9ee5db477985c542ea683e9f23ed32db55e35ef99c479
id: 23
filesize: 31620
filename: ecookbook-gantt.pdf
author_id: 2
description: Gantt chart as of May 11

BIN
test/fixtures/files/2019/05/190511141819_ecookbook-gantt.pdf View File


+ 10
- 0
test/functional/attachments_controller_test.rb View File

@@ -404,6 +404,16 @@ class AttachmentsControllerTest < Redmine::ControllerTest
assert_response 304
end

def test_thumbnail_for_pdf_should_be_png
Attachment.clear_thumbnails
@request.session[:user_id] = 2
get :thumbnail, :params => {
:id => 23 # ecookbook-gantt.pdf
}
assert_response :success
assert_equal 'image/png', response.content_type
end

def test_thumbnail_should_not_exceed_maximum_size
Redmine::Thumbnail.expects(:generate).with {|source, target, size| size == 800}


+ 16
- 5
test/unit/attachment_test.rb View File

@@ -425,13 +425,24 @@ class AttachmentTest < ActiveSupport::TestCase
if convert_installed?
def test_thumbnail_should_generate_the_thumbnail
set_fixtures_attachments_directory
attachment = Attachment.find(16)
Attachment.clear_thumbnails
to_test = []
# image/png
to_test << Attachment.find(16)
# application/pdf
if Redmine::Thumbnail.gs_available?
to_test << Attachment.find(23)
else
puts '(Ghostscript not available)'
end

assert_difference "Dir.glob(File.join(Attachment.thumbnails_storage_path, '*.thumb')).size" do
thumbnail = attachment.thumbnail
assert_equal "8e0294de2441577c529f170b6fb8f638_2654_100.thumb", File.basename(thumbnail)
assert File.exists?(thumbnail)
assert_difference "Dir.glob(File.join(Attachment.thumbnails_storage_path, '*.thumb')).size", to_test.size do
to_test.each do |attachment|
thumbnail = attachment.thumbnail
thumbnail_name = "#{attachment.digest}_#{attachment.filesize}_#{Setting.thumbnails_size}.thumb"
assert_equal thumbnail_name, File.basename(thumbnail)
assert File.exist?(thumbnail)
end
end
end


Loading…
Cancel
Save