ruby-on-rails - CarrierWave config.enable_processing = false 在 Rspec 的测试模式下不起作用
问题描述
当我使用以下工厂运行 Rspec 测试时,它会在 public/test/company/ 的本地存储库中创建文件
载波.rb
if Rails.env.test?
CarrierWave.configure do |config|
config.storage = :file
config.enable_processing = false
end
else
...
end
当我明确禁用处理时,我不明白为什么它会在测试模式下创建文件。我想在不处理和存储图像的情况下运行我的测试套件。关于改变什么的任何提示?
image_uploader.rb
class ImageUploader < CarrierWave::Uploader::Base
include CarrierWave::MiniMagick
def store_dir
"#{model.class.to_s.underscore}/#{model.id}"
end
process resize_to_fit: [250, 250]
version :thumb do
process resize_to_fit: [75, 75]
end
def extension_allowlist
%w(jpg jpeg gif png svg)
end
def filename
@name ||= "#{mounted_as}.png" if original_filename.present?
end
end
工厂.rb
factory :company do
name { 'stackoverflow' }
logo { File.new(Rails.root.join('spec', 'fixtures', 'companies', "1.png")) }
end
解决方案
推荐阅读
- java - 如何使用java存储、检索和更改值
- c - C:第二个 fget 的错误字符
- ios - Firebase删除用户云功能不起作用
- html - 为什么 CSS 百分比 (%) 高度应用于 flex 元素的孙子?
- javascript - 尝试使用节点 8 导出云功能
- python - fit() 缺少 1 个必需的位置参数:'y'
- sql - 全文搜索中权重参数的限制是多少
- r - 在 R 中重新缩放,固定为百分位数
- python - SKLearn Ordinal Encoder with Pandas Dataframe - 使用变量访问列
- javascript - 组件没有被渲染 - 动态路由反应