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/image_analyzer_test.rb
Ricardo Díaz 36e0ac3b53 Move #extract_metadata_from to ActiveStorage's TestHelper
ImageAnalyzerTest and VideoAnalyzerTest are defining the same helper,
since both use `#create_file_blob` that is defined in TestHelper, it
makes sense to move `#extract_metadata_from` to that side.
2018-04-25 15:28:30 -05:00

32 lines
992 B
Ruby

# frozen_string_literal: true
require "test_helper"
require "database/setup"
require "active_storage/analyzer/image_analyzer"
class ActiveStorage::Analyzer::ImageAnalyzerTest < ActiveSupport::TestCase
test "analyzing a JPEG image" do
blob = create_file_blob(filename: "racecar.jpg", content_type: "image/jpeg")
metadata = extract_metadata_from(blob)
assert_equal 4104, metadata[:width]
assert_equal 2736, metadata[:height]
end
test "analyzing a rotated JPEG image" do
blob = create_file_blob(filename: "racecar_rotated.jpg", content_type: "image/jpeg")
metadata = extract_metadata_from(blob)
assert_equal 2736, metadata[:width]
assert_equal 4104, metadata[:height]
end
test "analyzing an SVG image without an XML declaration" do
blob = create_file_blob(filename: "icon.svg", content_type: "image/svg+xml")
metadata = extract_metadata_from(blob)
assert_equal 792, metadata[:width]
assert_equal 584, metadata[:height]
end
end