Skip to content

Commit

Permalink
Analyzed does not mean they have height and width
Browse files Browse the repository at this point in the history
  • Loading branch information
brenogazzola committed Jan 10, 2025
1 parent 1344ce1 commit d781bf9
Show file tree
Hide file tree
Showing 7 changed files with 12 additions and 14 deletions.
2 changes: 1 addition & 1 deletion lib/vitals_image/optimizer/invariable.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def identified?
end

def analyzed?
metadata[:analyzed]
metadata[:analyzed] && metadata[:width] && metadata[:height]
end
end
end
2 changes: 1 addition & 1 deletion lib/vitals_image/optimizer/url.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def identified?
end

def analyzed?
metadata.analyzed
metadata.analyzed && metadata.width && metadata.height
end

def original_width
Expand Down
2 changes: 1 addition & 1 deletion lib/vitals_image/optimizer/variable.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def identified?
end

def analyzed?
metadata[:analyzed]
metadata[:analyzed] && metadata[:width] && metadata[:height]
end

def alpha?
Expand Down
1 change: 0 additions & 1 deletion test/dummy/config/application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion test/dummy/config/initializers/assets.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion test/helpers/tag_helper_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ class TagHelperTest < ActionView::TestCase

assert_equal %{<img class="vitals-image" loading="lazy" decoding="async" src="#{rails_storage_redirect_path(blob)}" />}, vitals_image_tag(blob, active_storage_route: :redirect)
assert_equal %{<img class="vitals-image" loading="lazy" decoding="async" src="#{rails_storage_proxy_path(blob)}" />}, vitals_image_tag(blob, active_storage_route: :proxy)
assert_equal %{<img class="vitals-image" loading="lazy" decoding="async" src="/images/vitals_image/logo.svg" />}, vitals_image_tag("vitals_image/logo.svg", active_storage_route: :public)
assert_equal %{<img class="vitals-image" loading="lazy" decoding="async" src="http://test.host/images/vitals_image/logo.svg" />}, vitals_image_tag("vitals_image/logo.svg", active_storage_route: :public)
end

test "that it handles tiny gif" do
Expand Down
16 changes: 8 additions & 8 deletions test/test_helper.rb
Original file line number Diff line number Diff line change
@@ -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
Expand Down

0 comments on commit d781bf9

Please # to comment.