Skip to content

armgit / spree

Public Imported from GitHub
0

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.

Adds active_storage_validations and mailer_logo validation

Robert Nowakowski1418a585a0a8
diff --git a/core/app/models/spree/store.rb b/core/app/models/spree/store.rb
index 6f81fde862..d588dac018 100644
--- a/core/app/models/spree/store.rb
+++ b/core/app/models/spree/store.rb
@@ -20,6 +20,8 @@ module Spree
has_one_attached :logo
has_one_attached :mailer_logo
+ validates :mailer_logo, content_type: ['image/png', 'image/jpg', 'image/jpeg']
+
before_save :ensure_default_exists_and_is_unique
before_destroy :validate_not_default
diff --git a/core/lib/spree/core.rb b/core/lib/spree/core.rb
index 23bdac7078..7d15275676 100644
--- a/core/lib/spree/core.rb
+++ b/core/lib/spree/core.rb
@@ -13,6 +13,7 @@ require 'premailer/rails'
require 'ransack'
require 'responders'
require 'state_machines-activerecord'
+require 'active_storage_validations'
# This is required because ActiveModel::Validations#invalid? conflicts with the
# invalid state of a Payment. In the future this should be removed.
diff --git a/core/spree_core.gemspec b/core/spree_core.gemspec
index d11c0184ab..a450fc4c53 100644
--- a/core/spree_core.gemspec
+++ b/core/spree_core.gemspec
@@ -50,6 +50,7 @@ Gem::Specification.new do |s|
s.add_dependency 'sprockets-rails'
s.add_dependency 'mini_magick', '>= 4.9.4', '< 4.11.0'
s.add_dependency 'image_processing', '~> 1.2'
+ s.add_dependency 'active_storage_validations', '~> 0.9'
s.add_development_dependency 'email_spec', '~> 2.2'
end