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.

Ability to use image factory without ActiveStorage (#11613)

Damian Legawiecdb5c17ba9973
diff --git a/core/lib/spree/testing_support/factories/image_factory.rb b/core/lib/spree/testing_support/factories/image_factory.rb
index eca1a233d0..9ceef6f222 100644
--- a/core/lib/spree/testing_support/factories/image_factory.rb
+++ b/core/lib/spree/testing_support/factories/image_factory.rb
@@ -1,7 +1,9 @@
FactoryBot.define do
factory :image, class: Spree::Image do
before(:create) do |image|
- image.attachment.attach(io: File.new(Spree::Core::Engine.root + 'spec/fixtures' + 'thinking-cat.jpg'), filename: 'thinking-cat.jpg')
+ if image.class.method_defined?(:attachment)
+ image.attachment.attach(io: File.new(Spree::Core::Engine.root + 'spec/fixtures' + 'thinking-cat.jpg'), filename: 'thinking-cat.jpg')
+ end
end
end
end