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
SD-1481 Change Image content type validation to use gem (#11419)
Kacper Mękarski81a43a54b6ad
diff --git a/core/app/models/spree/image/configuration/active_storage.rb b/core/app/models/spree/image/configuration/active_storage.rbindex 2e986b1e96..268771e6eb 100644--- a/core/app/models/spree/image/configuration/active_storage.rb+++ b/core/app/models/spree/image/configuration/active_storage.rb@@ -5,11 +5,10 @@ module Spreeextend ActiveSupport::Concernincluded do- validate :check_attachment_presence- validate :check_attachment_content_type-has_one_attached :attachment+ validates :attachment, attached: true, content_type: /\Aimage\/.*\z/+default_scope { includes(attachment_attachment: :blob) }def self.styles@@ -32,22 +31,6 @@ module Spreedef default_style:productend-- def accepted_image_types- %w(image/jpeg image/jpg image/png image/gif)- end-- def check_attachment_presence- unless attachment.attached?- errors.add(:attachment, :attachment_must_be_present)- end- end-- def check_attachment_content_type- if attachment.attached? && !attachment.content_type.in?(accepted_image_types)- errors.add(:attachment, :not_allowed_content_type)- end- endendendenddiff --git a/core/app/models/spree/taxon_image/configuration/active_storage.rb b/core/app/models/spree/taxon_image/configuration/active_storage.rbindex 2796fbebdb..bc8a05b0b3 100644--- a/core/app/models/spree/taxon_image/configuration/active_storage.rb+++ b/core/app/models/spree/taxon_image/configuration/active_storage.rb@@ -5,10 +5,10 @@ module Spreeextend ActiveSupport::Concernincluded do- validate :check_attachment_content_type-has_one_attached :attachment+ validates :attachment, content_type: /\Aimage\/.*\z/+default_scope { includes(attachment_attachment: :blob) }def self.styles@@ -21,16 +21,6 @@ module Spreedef default_style:miniend-- def accepted_image_types- %w(image/jpeg image/jpg image/png image/gif)- end-- def check_attachment_content_type- if attachment.attached? && !attachment.content_type.in?(accepted_image_types)- errors.add(:attachment, :not_allowed_content_type)- end- endendendend