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
add specs
Łukasz Adamczyk9d8188341cf4
diff --git a/core/app/models/spree/store.rb b/core/app/models/spree/store.rbindex 0227ac747f..e623c2e87e 100644--- a/core/app/models/spree/store.rb+++ b/core/app/models/spree/store.rb@@ -95,9 +95,8 @@ module Spreedef faviconreturn Config[:favicon] unless favicon_image.attached?- return favicon_image.variant(resize: '32x32') if favicon_image.variable?- favicon_image+ favicon_image.variant(resize: '32x32')endprivatediff --git a/core/lib/spree/testing_support/factories/store_factory.rb b/core/lib/spree/testing_support/factories/store_factory.rbindex 8f6f8126d4..b165e6fcc1 100644--- a/core/lib/spree/testing_support/factories/store_factory.rb+++ b/core/lib/spree/testing_support/factories/store_factory.rb@@ -12,5 +12,14 @@ FactoryBot.define dofacebook { 'spreecommerce' }twitter { 'spreecommerce' }instagram { 'spreecommerce' }++ trait :with_favicon do+ favicon_image do+ Rack::Test::UploadedFile.new(+ Spree::Core::Engine.root.join('spec', 'fixtures', 'favicon.ico'),+ 'image/x-icon'+ )+ end+ endendenddiff --git a/core/spec/fixtures/favicon.ico b/core/spec/fixtures/favicon.iconew file mode 100644index 0000000000..b5b89e3563Binary files /dev/null and b/core/spec/fixtures/favicon.ico differdiff --git a/core/spec/helpers/base_helper_spec.rb b/core/spec/helpers/base_helper_spec.rbindex 38267788cd..9c17931e45 100644--- a/core/spec/helpers/base_helper_spec.rb+++ b/core/spec/helpers/base_helper_spec.rb@@ -326,4 +326,13 @@ describe Spree::BaseHelper, type: :helper doendendend++ describe '#favicon_path' do+ let(:current_store) { create(:store, :with_favicon) }++ it do+ expect(favicon_path).to end_with('favicon.ico')+ expect(URI.parse(favicon_path).host).to be_present+ end+ endenddiff --git a/core/spec/models/spree/store_spec.rb b/core/spec/models/spree/store_spec.rbindex 2233798d44..19a18fb0ac 100644--- a/core/spec/models/spree/store_spec.rb+++ b/core/spec/models/spree/store_spec.rb@@ -313,4 +313,26 @@ describe Spree::Store, type: :model doit { expect { store.save! }.not_to change(store, :supported_currencies) }endend++ describe '#favicon' do+ subject(:favicon) { store.favicon }++ context 'with an attached favicon image' do+ let(:store) { create(:store, :with_favicon) }+ let(:favicon_variation) { favicon.processed.variation }++ it 'returns a resized favicon' do+ expect(favicon_variation).to be_present+ expect(favicon_variation.transformations.fetch(:resize)).to eq('32x32')+ end+ end++ context 'without an attached favicon image' do+ let(:store) { create(:store) }++ it 'returns a default favicon' do+ expect(favicon).to eq('favicon.ico')+ end+ end+ endend