1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00
rails--rails/activestorage/test/analyzer/video_analyzer_test.rb

36 lines
1.2 KiB
Ruby
Raw Normal View History

# frozen_string_literal: true
require "test_helper"
require "database/setup"
require "active_storage/analyzer/video_analyzer"
class ActiveStorage::Analyzer::VideoAnalyzerTest < ActiveSupport::TestCase
test "analyzing a video" do
blob = create_file_blob(filename: "video.mp4", content_type: "video/mp4")
metadata = blob.tap(&:analyze).metadata
assert_equal 640, metadata[:width]
assert_equal 480, metadata[:height]
assert_equal [4, 3], metadata[:aspect_ratio]
assert_equal 5.166648, metadata[:duration]
assert_not_includes metadata, :angle
end
test "analyzing a rotated video" do
blob = create_file_blob(filename: "rotated_video.mp4", content_type: "video/mp4")
metadata = blob.tap(&:analyze).metadata
assert_equal 480, metadata[:width]
assert_equal 640, metadata[:height]
assert_equal [4, 3], metadata[:aspect_ratio]
assert_equal 5.227975, metadata[:duration]
assert_equal 90, metadata[:angle]
end
test "analyzing a video without a video stream" do
blob = create_file_blob(filename: "video_without_video_stream.mp4", content_type: "video/mp4")
2018-01-15 13:06:17 -05:00
assert_equal({ "analyzed" => true, "identified" => true }, blob.tap(&:analyze).metadata)
end
end