存储图像以测试上传和删除的好方法是什么?

What is the good way to store images for testing upload and removal?

用于测试上传和删除的图像存储的好方法是什么?

我为我的产品编写了一些固定装置。

产品具有存储在文件夹中的附加图像 spec/fixtures/product/attachments/pull_noir_1.jpg

当我启动删除产品规格时,图像从文件夹中删除,然后下一个规格失败,因为找不到图像(是它已被删除)... public/uploads/product/attachments/683902633/pull_rouge_1.jpg

我应该如何设置我的上传器以及我应该将图片保存在哪里?

这是我的一些装置 products.yml

warm_sweat:
  title: Gros pull
  price: 30
  color: Noir
  category: pull
  user: nelly
  attachments: pull_rouge_1.jpg

black_k_l:
  title: Pull Kenzaro
  price: 20
  color: Noir
  category: pull
  user: nelly
  attachments: pull_noir_1.jpg

我的attachement_uploader.rb

class AttachmentUploader < CarrierWave::Uploader::Base
  include CarrierWave::MiniMagick

  storage :file

  if Rails.env.production?
    storage :fog
  else
    storage :file
  end

  version :thumb do
     process resize_to_fill: [280, 280]
   end

  def default_url(*args)
     "/images/fallback/" + [version_name, "random.jpg"].compact.join('_')
   end

  def store_dir      
    "uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}"
  end

  def extension_white_list
    %w(jpg jpeg gif png)
  end
end

EDIT I re added the #{model.id} Still facing the same probleme

失败

 ActionController::RoutingError:
           No route matches [GET] /uploads/product/attachments/683902633/pull_rouge_1.jpg

我认为您不需要我的规格,但请随时询问我是否需要用更多代码更新问题。

我的 rails_helper 缺少这个:

CarrierWave.configure do |config|
  config.root              = Rails.root.join('spec/fixtures')
  config.cache_only        = true
  config.enable_processing = false
  config.base_path         = "/"
end