aboutsummaryrefslogblamecommitdiffstats
path: root/test/models/variant_test.rb
blob: 7d52f005a7ec4d6173e00271a039a2a5d1b80ae6 (plain) (tree)
1
2
3
4
5
6
7
8
9

                        
 
                                                          
          
                                                     


                             
                                                        
                                                   



                                       
     
 
                                            
                                                                          
                                                   



                                       
                                         

     
require "test_helper"
require "database/setup"

class ActiveStorage::VariantTest < ActiveSupport::TestCase
  setup do
    @blob = create_image_blob filename: "racecar.jpg"
  end

  test "resized variation" do
    variant = @blob.variant(resize: "100x100").processed
    assert_match /racecar.jpg/, variant.service_url

    image = read_image_variant(variant)
    assert_equal 100, image.width
    assert_equal 67, image.height
  end

  test "resized and monochrome variation" do
    variant = @blob.variant(resize: "100x100", monochrome: true).processed
    assert_match /racecar.jpg/, variant.service_url

    image = read_image_variant(variant)
    assert_equal 100, image.width
    assert_equal 67, image.height
    assert_match /Gray/, image.colorspace
  end
end