mirror of
https://github.com/redmine/redmine.git
synced 2025-11-14 09:16:02 +01:00
Test for r18158 (#22481).
Patch by Go MAEDA. git-svn-id: http://svn.redmine.org/redmine/trunk@18159 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
14
test/fixtures/attachments.yml
vendored
14
test/fixtures/attachments.yml
vendored
@@ -295,3 +295,17 @@ attachments_022:
|
|||||||
author_id: 1
|
author_id: 1
|
||||||
description: unknown type
|
description: unknown type
|
||||||
content_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
vendored
Normal file
BIN
test/fixtures/files/2019/05/190511141819_ecookbook-gantt.pdf
vendored
Normal file
Binary file not shown.
@@ -404,6 +404,16 @@ class AttachmentsControllerTest < Redmine::ControllerTest
|
|||||||
assert_response 304
|
assert_response 304
|
||||||
end
|
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
|
def test_thumbnail_should_not_exceed_maximum_size
|
||||||
Redmine::Thumbnail.expects(:generate).with {|source, target, size| size == 800}
|
Redmine::Thumbnail.expects(:generate).with {|source, target, size| size == 800}
|
||||||
|
|
||||||
|
|||||||
@@ -425,13 +425,24 @@ class AttachmentTest < ActiveSupport::TestCase
|
|||||||
if convert_installed?
|
if convert_installed?
|
||||||
def test_thumbnail_should_generate_the_thumbnail
|
def test_thumbnail_should_generate_the_thumbnail
|
||||||
set_fixtures_attachments_directory
|
set_fixtures_attachments_directory
|
||||||
attachment = Attachment.find(16)
|
|
||||||
Attachment.clear_thumbnails
|
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
|
assert_difference "Dir.glob(File.join(Attachment.thumbnails_storage_path, '*.thumb')).size", to_test.size do
|
||||||
thumbnail = attachment.thumbnail
|
to_test.each do |attachment|
|
||||||
assert_equal "8e0294de2441577c529f170b6fb8f638_2654_100.thumb", File.basename(thumbnail)
|
thumbnail = attachment.thumbnail
|
||||||
assert File.exists?(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
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user