diff options
author | Terence Lee <hone02@gmail.com> | 2018-02-05 19:33:35 -0600 |
---|---|---|
committer | George Claghorn <george@basecamp.com> | 2018-03-06 13:33:33 -0500 |
commit | 0b717c20458d12191f479fc693dd1ca1eb11c050 (patch) | |
tree | 6bcd9dd08f792a35235a96f392a79fd2ac0cdbc2 /activestorage/test | |
parent | 060ed201e444785135ce9a4baea069079257295e (diff) | |
download | rails-0b717c20458d12191f479fc693dd1ca1eb11c050.tar.gz rails-0b717c20458d12191f479fc693dd1ca1eb11c050.tar.bz2 rails-0b717c20458d12191f479fc693dd1ca1eb11c050.zip |
Provide an alternative PDF previewer based on Poppler
mutool is licensed under the Affero GPL, which has strict distribution requirements.
Poppler is licensed under the more liberal GPL, making it a good alternative for those who can't use mutool.
Diffstat (limited to 'activestorage/test')
-rw-r--r-- | activestorage/test/previewer/mupdf_previewer_test.rb (renamed from activestorage/test/previewer/pdf_previewer_test.rb) | 6 | ||||
-rw-r--r-- | activestorage/test/previewer/poppler_pdf_previewer_test.rb | 23 |
2 files changed, 26 insertions, 3 deletions
diff --git a/activestorage/test/previewer/pdf_previewer_test.rb b/activestorage/test/previewer/mupdf_previewer_test.rb index fe32f39be4..6c2db6fcbf 100644 --- a/activestorage/test/previewer/pdf_previewer_test.rb +++ b/activestorage/test/previewer/mupdf_previewer_test.rb @@ -3,15 +3,15 @@ require "test_helper" require "database/setup" -require "active_storage/previewer/pdf_previewer" +require "active_storage/previewer/mupdf_previewer" -class ActiveStorage::Previewer::PDFPreviewerTest < ActiveSupport::TestCase +class ActiveStorage::Previewer::MuPDFPreviewerTest < ActiveSupport::TestCase setup do @blob = create_file_blob(filename: "report.pdf", content_type: "application/pdf") end test "previewing a PDF document" do - ActiveStorage::Previewer::PDFPreviewer.new(@blob).preview do |attachable| + ActiveStorage::Previewer::MuPDFPreviewer.new(@blob).preview do |attachable| assert_equal "image/png", attachable[:content_type] assert_equal "report.png", attachable[:filename] diff --git a/activestorage/test/previewer/poppler_pdf_previewer_test.rb b/activestorage/test/previewer/poppler_pdf_previewer_test.rb new file mode 100644 index 0000000000..2b41c8b642 --- /dev/null +++ b/activestorage/test/previewer/poppler_pdf_previewer_test.rb @@ -0,0 +1,23 @@ +# frozen_string_literal: true + +require "test_helper" +require "database/setup" + +require "active_storage/previewer/poppler_pdf_previewer" + +class ActiveStorage::Previewer::PopplerPDFPreviewerTest < ActiveSupport::TestCase + setup do + @blob = create_file_blob(filename: "report.pdf", content_type: "application/pdf") + end + + test "previewing a PDF document" do + ActiveStorage::Previewer::PopplerPDFPreviewer.new(@blob).preview do |attachable| + assert_equal "image/png", attachable[:content_type] + assert_equal "report.png", attachable[:filename] + + image = MiniMagick::Image.read(attachable[:io]) + assert_equal 612, image.width + assert_equal 792, image.height + end + end +end |