From d781bf92deddf6117f8828b10ec71df3d6f2d108 Mon Sep 17 00:00:00 2001 From: Breno Gazzola Date: Fri, 10 Jan 2025 10:49:21 -0300 Subject: [PATCH] Analyzed does not mean they have height and width --- lib/vitals_image/optimizer/invariable.rb | 2 +- lib/vitals_image/optimizer/url.rb | 2 +- lib/vitals_image/optimizer/variable.rb | 2 +- test/dummy/config/application.rb | 1 - test/dummy/config/initializers/assets.rb | 1 - test/helpers/tag_helper_test.rb | 2 +- test/test_helper.rb | 16 ++++++++-------- 7 files changed, 12 insertions(+), 14 deletions(-) diff --git a/lib/vitals_image/optimizer/invariable.rb b/lib/vitals_image/optimizer/invariable.rb index e2b63d2..fbf5528 100644 --- a/lib/vitals_image/optimizer/invariable.rb +++ b/lib/vitals_image/optimizer/invariable.rb @@ -38,7 +38,7 @@ def identified? end def analyzed? - metadata[:analyzed] + metadata[:analyzed] && metadata[:width] && metadata[:height] end end end diff --git a/lib/vitals_image/optimizer/url.rb b/lib/vitals_image/optimizer/url.rb index c33bb62..61bb964 100644 --- a/lib/vitals_image/optimizer/url.rb +++ b/lib/vitals_image/optimizer/url.rb @@ -26,7 +26,7 @@ def identified? end def analyzed? - metadata.analyzed + metadata.analyzed && metadata.width && metadata.height end def original_width diff --git a/lib/vitals_image/optimizer/variable.rb b/lib/vitals_image/optimizer/variable.rb index 217e701..11418b5 100644 --- a/lib/vitals_image/optimizer/variable.rb +++ b/lib/vitals_image/optimizer/variable.rb @@ -32,7 +32,7 @@ def identified? end def analyzed? - metadata[:analyzed] + metadata[:analyzed] && metadata[:width] && metadata[:height] end def alpha? diff --git a/test/dummy/config/application.rb b/test/dummy/config/application.rb index e92909a..2274c1c 100644 --- a/test/dummy/config/application.rb +++ b/test/dummy/config/application.rb @@ -14,7 +14,6 @@ # require "action_text/engine" require "action_view/railtie" # require "action_cable/engine" -require "sprockets/railtie" require "rails/test_unit/railtie" # Require the gems listed in Gemfile, including any gems diff --git a/test/dummy/config/initializers/assets.rb b/test/dummy/config/initializers/assets.rb index 101a290..a57d595 100644 --- a/test/dummy/config/initializers/assets.rb +++ b/test/dummy/config/initializers/assets.rb @@ -3,7 +3,6 @@ # Be sure to restart your server when you modify this file. # Version of your assets, change this if you want to expire all your assets. -Rails.application.config.assets.version = "1.0" # Add additional assets to the asset load path. # Rails.application.config.assets.paths << Emoji.images_path diff --git a/test/helpers/tag_helper_test.rb b/test/helpers/tag_helper_test.rb index 2f94f9b..705ec01 100644 --- a/test/helpers/tag_helper_test.rb +++ b/test/helpers/tag_helper_test.rb @@ -119,7 +119,7 @@ class TagHelperTest < ActionView::TestCase assert_equal %{}, vitals_image_tag(blob, active_storage_route: :redirect) assert_equal %{}, vitals_image_tag(blob, active_storage_route: :proxy) - assert_equal %{}, vitals_image_tag("vitals_image/logo.svg", active_storage_route: :public) + assert_equal %{}, vitals_image_tag("vitals_image/logo.svg", active_storage_route: :public) end test "that it handles tiny gif" do diff --git a/test/test_helper.rb b/test/test_helper.rb index efd1b1a..3885482 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -1,23 +1,23 @@ # frozen_string_literal: true +# Configure Rails Environment ENV["RAILS_ENV"] = "test" -require_relative "../test/dummy/config/environment" +require_relative "../test/dummy/config/environment" ActiveRecord::Migrator.migrations_paths = [File.expand_path("../test/dummy/db/migrate", __dir__)] ActiveRecord::Migrator.migrations_paths << File.expand_path("../db/migrate", __dir__) -ActiveRecord::Base.connection.migration_context.migrate - +ActiveRecord::Tasks::DatabaseTasks.migrate require "rails/test_help" # Load fixtures from the engine - -if ActiveSupport::TestCase.respond_to?(:fixture_path=) - ActiveSupport::TestCase.fixture_path = File.expand_path("fixtures", __dir__) - ActionDispatch::IntegrationTest.fixture_path = ActiveSupport::TestCase.fixture_path - ActiveSupport::TestCase.file_fixture_path = ActiveSupport::TestCase.fixture_path + "/files" +if ActiveSupport::TestCase.respond_to?(:fixture_paths=) + ActiveSupport::TestCase.fixture_paths = [ File.expand_path("fixtures", __dir__) ] + ActionDispatch::IntegrationTest.fixture_paths = ActiveSupport::TestCase.fixture_paths + ActiveSupport::TestCase.file_fixture_path = File.expand_path("fixtures", __dir__) + "/files" ActiveSupport::TestCase.fixtures :all end + def create_file_blob(filename:, content_type:, metadata: nil) ActiveStorage::Blob.create_and_upload! io: file_fixture(filename).open, filename: filename, content_type: content_type, metadata: metadata end