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 (TaxonImage)

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