I\'m working on upgrading from attachment_fu to carrierwave, since attachment_fu is broken in rails 3.
None of the tests are able to run, because we have invalid fixture
I know it is old but, for some that uses Rails 5 + RSpec + CarrierWave + Fixtures:
Edit test configs:
# config/initializers/carrierwave.rb
if Rails.env.test?
class NullStorage < CarrierWave::Storage::Abstract
def store!(_file)
_file
end
def retrieve!(identifier)
file = Rails.root.join('spec', 'fixtures', 'files', identifier)
tmp = Rails.root.join('tmp', 'blank_tmp.jpg')
FileUtils.cp(file, tmp)
CarrierWave::SanitizedFile.new(tmp)
end
end
CarrierWave.configure do |config|
config.storage = NullStorage
config.enable_processing = false
end
end
Create a folder and a file, for example spec/fixtures/files/some-user-photo.jpg
and, create some fixtures, for example:
first_user:
avatar: "some-user-photo.jpg"
name: "First User Name"
about: "First User About Long Text..."
lat: 0.001
lng: 0.001
created_at: <%= Time.current - 3.days %>
updated_at: <%= Time.current - 3.days %>
That is enough to make the test understand that this user has an avatar