aboutsummaryrefslogblamecommitdiffstats
path: root/activestorage/test/analyzer/image_analyzer_test.rb
blob: 0d9f24c5c1f701b441f5da347ded45c73863f366 (plain) (tree)
1
2
3
4
5
6
7
8
9







                                                                          
                                  





                                                                                







                                                                                
   
# 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 = blob.tap(&:analyze).metadata

    assert_equal 4104, metadata[:width]
    assert_equal 2736, 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 = blob.tap(&:analyze).metadata

    assert_equal 792, metadata[:width]
    assert_equal 584, metadata[:height]
  end
end