aboutsummaryrefslogtreecommitdiffstats
path: root/activestorage/test/previewer/video_previewer_test.rb
diff options
context:
space:
mode:
authorGeorge Claghorn <george.claghorn@gmail.com>2017-09-28 16:43:37 -0400
committerGitHub <noreply@github.com>2017-09-28 16:43:37 -0400
commitd30586211b41e018869a1a3f4e3af778a31591db (patch)
tree664028edf779b3a6d55e08c2503cfe91e2309eff /activestorage/test/previewer/video_previewer_test.rb
parentf7b4be40410432b77e0c5d114b0ce73480ff984d (diff)
downloadrails-d30586211b41e018869a1a3f4e3af778a31591db.tar.gz
rails-d30586211b41e018869a1a3f4e3af778a31591db.tar.bz2
rails-d30586211b41e018869a1a3f4e3af778a31591db.zip
Preview PDFs and videos
Diffstat (limited to 'activestorage/test/previewer/video_previewer_test.rb')
-rw-r--r--activestorage/test/previewer/video_previewer_test.rb20
1 files changed, 20 insertions, 0 deletions
diff --git a/activestorage/test/previewer/video_previewer_test.rb b/activestorage/test/previewer/video_previewer_test.rb
new file mode 100644
index 0000000000..967d5d5ba9
--- /dev/null
+++ b/activestorage/test/previewer/video_previewer_test.rb
@@ -0,0 +1,20 @@
+# frozen_string_literal: true
+
+require "active_storage/previewer/video_previewer"
+
+class ActiveStorage::Previewer::VideoPreviewerTest < ActiveSupport::TestCase
+ setup do
+ @blob = create_file_blob(filename: "video.mp4", content_type: "video/mp4")
+ end
+
+ test "previewing an MP4 video" do
+ ActiveStorage::Previewer::VideoPreviewer.new(@blob).preview do |attachable|
+ assert_equal "image/png", attachable[:content_type]
+ assert_equal "video.png", attachable[:filename]
+
+ image = MiniMagick::Image.read(attachable[:io])
+ assert_equal 640, image.width
+ assert_equal 480, image.height
+ end
+ end
+end