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
Storefront: fix for spree images
Szymon Chorobski0044d5a9a63c
diff --git a/core/lib/spree/testing_support/factories/post_factory.rb b/core/lib/spree/testing_support/factories/post_factory.rbindex a1a3ec7952..2223e0c8aa 100644--- a/core/lib/spree/testing_support/factories/post_factory.rb+++ b/core/lib/spree/testing_support/factories/post_factory.rb@@ -6,5 +6,9 @@ FactoryBot.define dopublished_at { Time.current }author { create(:admin_user) }store { Spree::Store.default || create(:store) }++ trait :with_image do+ image { Rack::Test::UploadedFile.new(Spree::Core::Engine.root.join('spec/fixtures/thinking-cat.jpg'), 'image/jpeg') }+ endendenddiff --git a/storefront/app/helpers/spree/storefront_helper.rb b/storefront/app/helpers/spree/storefront_helper.rbindex ef5d27c2f6..5d91b90ad9 100644--- a/storefront/app/helpers/spree/storefront_helper.rb+++ b/storefront/app/helpers/spree/storefront_helper.rb@@ -1,6 +1,7 @@module Spreemodule StorefrontHelperinclude BaseHelper+ include Spree::ImagesHelperinclude Heroicon::Engine.helpers# Renders the storefront partials for the given section.@@ -71,9 +72,9 @@ module Spreedef show_account_pane?!try_spree_current_user &&- (defined?(spree_login_path) && !paths_equal?(canonical_path, spree_login_path)) &&- (defined?(spree_signup_path) && !paths_equal?(canonical_path, spree_signup_path)) &&- (defined?(spree_forgot_password_path) && !paths_equal?(canonical_path, spree_forgot_password_path))+ defined?(spree_login_path) && !paths_equal?(canonical_path, spree_login_path) &&+ defined?(spree_signup_path) && !paths_equal?(canonical_path, spree_signup_path) &&+ defined?(spree_forgot_password_path) && !paths_equal?(canonical_path, spree_forgot_password_path)enddef paths_equal?(path1, path2)diff --git a/storefront/spec/features/post_details_page_spec.rb b/storefront/spec/features/post_details_page_spec.rbindex 953548bd32..4c7ae760a7 100644--- a/storefront/spec/features/post_details_page_spec.rb+++ b/storefront/spec/features/post_details_page_spec.rb@@ -1,11 +1,11 @@require 'spec_helper'-RSpec.describe 'Post details page', type: :feature, js: true do+RSpec.describe 'Post details page', :js, type: :feature dodescribe 'JSON-LD data' dolet(:store) { Spree::Store.default }let!(:post) docreate(- :post,+ :post, :with_image,post_category: post_category,tag_list: tags,title: 'New products on sale!',@@ -27,11 +27,11 @@ RSpec.describe 'Post details page', type: :feature, js: true dolet(:post_category) { create(:post_category, title: 'Articles') }it 'renders BlogPosting JSON-LD' do- expect(json_ld).to eq(+ expect(json_ld).to match('@context' => 'https://schema.org','@type' => 'BlogPosting','headline' => 'New products on sale!',- 'image' => [],+ 'image' => array_including(kind_of(String)),'datePublished' => post.published_at.iso8601,'dateModified' => post.updated_at.iso8601,'author' => [@@ -44,7 +44,7 @@ RSpec.describe 'Post details page', type: :feature, js: true doendit 'renders BreadcrumbList JSON-LD with a link to category page' do- expect(json_ld_breadcrumbs).to eq(+ expect(json_ld_breadcrumbs).to match({'@context' => 'https://schema.org','@type' => 'BreadcrumbList',@@ -82,11 +82,11 @@ RSpec.describe 'Post details page', type: :feature, js: true dolet(:post_category) { nil }it 'renders JSON-LD' do- expect(json_ld).to eq(+ expect(json_ld).to match('@context' => 'https://schema.org','@type' => 'BlogPosting','headline' => 'New products on sale!',- 'image' => [],+ 'image' => array_including(kind_of(String)),'datePublished' => post.published_at.iso8601,'dateModified' => post.updated_at.iso8601,'author' => [