Module: Spree::TestingSupport::ImageHelpers
- Defined in:
- lib/spree/testing_support/image_helpers.rb
Instance Method Summary collapse
Instance Method Details
#create_image(attachable, file) ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 16 |
# File 'lib/spree/testing_support/image_helpers.rb', line 4 def create_image(attachable, file) # user paperclip to attach an image if Rails.application.config.use_paperclip attachable.images.create!(attachment: file) # use ActiveStorage (default) else image = attachable.images.new image..attach(io: file, filename: File.basename(file)) image.save! file.rewind image end end |