Open Source Platform for DTC, B2B Commerce, Marketplaces & Omnichannel. REST APIs, TypeScript SDKs, and production-ready Next.js storefront. Self-host it. Own your data. No vendor lock-in. Zero platform fees.
Ruby b2b-commercee-commerceecommerceecommerce-apiecommerce-frameworkecommerce-platformheadlessheadless-commerceheadless-ecommercemarketplacemulti-tenantmulti-vendormulti-vendor-ecommerceopen-sourcespree-commerce
active storage blob partial fix
Szymon Chorobskid5a3db7124bf
diff --git a/core/app/helpers/spree/images_helper.rb b/core/app/helpers/spree/images_helper.rbindex 322c27d613..9e285732ed 100644--- a/core/app/helpers/spree/images_helper.rb+++ b/core/app/helpers/spree/images_helper.rb@@ -18,10 +18,10 @@ module Spreewidth = options[:width]height = options[:height]- width = width * 2 if width.present?- height = height * 2 if height.present?+ width *= 2 if width.present?+ height *= 2 if height.present?- return unless image.attached?+ return if image.respond_to?(:attached?) && !image.attached?return unless image.variable?if width.present? && height.present?@@ -51,17 +51,18 @@ module Spreereturn unless heightreturn if height.zero?- w, h = width.to_f, height.to_f+ w = width.to_f+ h = height.to_f# Always return width / height, flipping if needed- if h > w- ratio = h / w- elsif h < w- ratio = w / h- else- # h == w, square image- ratio = 1.0- end+ ratio = if h > w+ h / w+ elsif h < w+ w / h+ else+ # h == w, square image+ 1.0+ endratio.round(3)enddiff --git a/core/spec/helpers/images_helper_spec.rb b/core/spec/helpers/images_helper_spec.rbindex a4b085f0be..7306ac9221 100644--- a/core/spec/helpers/images_helper_spec.rb+++ b/core/spec/helpers/images_helper_spec.rb@@ -23,6 +23,10 @@ describe Spree::ImagesHelper, type: :helper doenddescribe '#spree_image_url' do+ it 'supports blob' do+ expect(helper.spree_image_url(image.blob)).to eq(helper.spree_image_url(image))+ end+context 'when image is not attached' dobefore doallow(image).to receive(:attached?).and_return(false)@@ -35,8 +39,7 @@ describe Spree::ImagesHelper, type: :helper docontext 'when image is not variable' dobefore do- allow(image).to receive(:attached?).and_return(true)- allow(image).to receive(:variable?).and_return(false)+ allow(image).to receive_messages(attached?: true, variable?: false)endit 'returns nil' do@@ -82,8 +85,7 @@ describe Spree::ImagesHelper, type: :helper docontext 'when aspect_ratio is present in metadata' dobefore do- allow(attachment).to receive(:analyzed?).and_return(true)- allow(attachment).to receive(:metadata).and_return({ 'aspect_ratio' => 1.5 })+ allow(attachment).to receive_messages(analyzed?: true, metadata: { 'aspect_ratio' => 1.5 })endit 'returns the aspect ratio' do@@ -93,8 +95,7 @@ describe Spree::ImagesHelper, type: :helper docontext 'when calculating aspect ratio from dimensions' dobefore do- allow(attachment).to receive(:analyzed?).and_return(true)- allow(attachment).to receive(:metadata).and_return({ 'width' => width, 'height' => height })+ allow(attachment).to receive_messages(analyzed?: true, metadata: { 'width' => width, 'height' => height })endcontext 'when height is greater than width' do