Sha256: 55e4301f0bddf5f97f3e60f52babaa9d64c43b15b2f51de3608e433e65ac97f0

Contents?: true

Size: 1.72 KB

Versions: 17

Compression:

Stored size: 1.72 KB

Contents

require 'bundler/inline'

gemfile(true) do
  source 'https://rubygems.org'

  git_source(:github) { |repo| "https://github.com/#{repo}.git" }

  gem 'rails', '6.0.3'
  gem 'sqlite3'
  gem 'format_parser', path: './'
end

require 'active_record/railtie'
require 'active_storage/engine'
require 'tmpdir'

class TestApp < Rails::Application
  config.root = __dir__
  config.hosts << 'example.org'
  config.eager_load = false
  config.session_store :cookie_store, key: 'cookie_store_key'
  secrets.secret_key_base = 'secret_key_base'

  config.logger = Logger.new('/dev/null')

  config.active_storage.service = :local
  config.active_storage.service_configurations = {
    local: {
      root: Dir.tmpdir,
      service: 'Disk'
    }
  }

  config.active_storage.analyzers.prepend FormatParser::ActiveStorage::BlobAnalyzer
end

ENV['DATABASE_URL'] = 'sqlite3::memory:'

Rails.application.initialize!

require ActiveStorage::Engine.root.join('db/migrate/20170806125915_create_active_storage_tables.rb').to_s

ActiveRecord::Schema.define do
  CreateActiveStorageTables.new.change

  create_table :users, force: true
end

class User < ActiveRecord::Base
  has_one_attached :profile_picture
end

require 'minitest/autorun'
require 'open-uri'

describe User do
  describe "profile_picture's metadatas" do
    it 'parse metadatas with format_parser' do
      user = User.create
      user.profile_picture.attach(
        filename: 'cat.png',
        io: URI.open('https://freesvg.org/img/1416155153.png')
      )

      user.profile_picture.analyze

      _(user.profile_picture.metadata[:width_px]).must_equal 500
      _(user.profile_picture.metadata[:height_px]).must_equal 296
      _(user.profile_picture.metadata[:color_mode]).must_equal 'rgba'
    end
  end
end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
format_parser-0.29.1 spec/integration/active_storage/rails_app.rb
format_parser-0.29.0 spec/integration/active_storage/rails_app.rb
format_parser-0.28.0 spec/integration/active_storage/rails_app.rb
format_parser-0.27.0 spec/integration/active_storage/rails_app.rb
format_parser-0.26.0 spec/integration/active_storage/rails_app.rb
format_parser-0.25.6 spec/integration/active_storage/rails_app.rb
format_parser-0.25.5 spec/integration/active_storage/rails_app.rb
format_parser-0.25.4 spec/integration/active_storage/rails_app.rb
format_parser-0.25.3 spec/integration/active_storage/rails_app.rb
format_parser-0.25.2 spec/integration/active_storage/rails_app.rb
format_parser-0.25.1 spec/integration/active_storage/rails_app.rb
format_parser-0.25.0 spec/integration/active_storage/rails_app.rb
format_parser-0.24.2 spec/integration/active_storage/rails_app.rb
format_parser-0.24.1 spec/integration/active_storage/rails_app.rb
format_parser-0.24.0 spec/integration/active_storage/rails_app.rb
format_parser-0.23.1 spec/integration/active_storage/rails_app.rb
format_parser-0.23.0 spec/integration/active_storage/rails_app.rb