diff options
author | Go MAEDA <maeda@farend.jp> | 2019-05-12 05:43:50 +0000 |
---|---|---|
committer | Go MAEDA <maeda@farend.jp> | 2019-05-12 05:43:50 +0000 |
commit | 96b6bdfb771426f8c545bc3e49c8b0de0085fb0f (patch) | |
tree | 5e7d1dcc36ab00005a74a59ce830a9159f0ddf0a | |
parent | c4a4133178b83c2c115df1947302c785b2885467 (diff) | |
download | redmine-96b6bdfb771426f8c545bc3e49c8b0de0085fb0f.tar.gz redmine-96b6bdfb771426f8c545bc3e49c8b0de0085fb0f.zip |
Test for r18158 (#22481).
Patch by Go MAEDA.
git-svn-id: http://svn.redmine.org/redmine/trunk@18159 e93f8b46-1217-0410-a6f0-8f06a7374b81
-rw-r--r-- | test/fixtures/attachments.yml | 14 | ||||
-rw-r--r-- | test/fixtures/files/2019/05/190511141819_ecookbook-gantt.pdf | bin | 0 -> 31620 bytes | |||
-rw-r--r-- | test/functional/attachments_controller_test.rb | 10 | ||||
-rw-r--r-- | test/unit/attachment_test.rb | 21 |
4 files changed, 40 insertions, 5 deletions
diff --git a/test/fixtures/attachments.yml b/test/fixtures/attachments.yml index 5a6334565..ff126a8c6 100644 --- a/test/fixtures/attachments.yml +++ b/test/fixtures/attachments.yml @@ -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 diff --git a/test/fixtures/files/2019/05/190511141819_ecookbook-gantt.pdf b/test/fixtures/files/2019/05/190511141819_ecookbook-gantt.pdf Binary files differnew file mode 100644 index 000000000..f489d0a15 --- /dev/null +++ b/test/fixtures/files/2019/05/190511141819_ecookbook-gantt.pdf diff --git a/test/functional/attachments_controller_test.rb b/test/functional/attachments_controller_test.rb index af5421ecc..67cdb4933 100644 --- a/test/functional/attachments_controller_test.rb +++ b/test/functional/attachments_controller_test.rb @@ -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} diff --git a/test/unit/attachment_test.rb b/test/unit/attachment_test.rb index 384ee1fd7..180439a16 100644 --- a/test/unit/attachment_test.rb +++ b/test/unit/attachment_test.rb @@ -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 |