Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Add the cache_only configuration option #1456

Merged
merged 1 commit into from
Sep 30, 2014

Conversation

jeffkreeftmeijer
Copy link
Contributor

Hey everyone,

I’ve been trying to get test fixtures working on CarrierWave, and came up with a solution that works by monkey-patching CarrierWave::Mount::Mounter#store!. That way, you prevent CarrierWave from moving the files from the cache directory to the store_dir.

It’d be great to be able to set a configuration option in your tests instead of breaking a method in the mounter, so I added a configuration option called “cache_only”, which does the same thing. What do you think?

@bensie
Copy link
Member

bensie commented Sep 30, 2014

Thanks @jeffkreeftmeijer looks great!

bensie added a commit that referenced this pull request Sep 30, 2014
Add the cache_only configuration option
@bensie bensie merged commit c82ad88 into carrierwaveuploader:master Sep 30, 2014
@pdobb
Copy link

pdobb commented Jun 7, 2017

@jeffkreeftmeijer How do we use this? Your blog post doesn't show how still and I'm not sure how to set the configuration option in Carrierwave in my test_helper. Thanks for any help and for your contribution!

UPDATE
I think I figured it out:

class ActiveSupport::TestCase
  # ...

  CarrierWave.configure do |config|
    config.root = Rails.root.join("test/fixtures/files")
    config.cache_only = true
    config.enable_processing = false
    config.storage = :file
  end

  def after_teardown
    super
    CarrierWave.clean_cached_files!(0)
  end
end

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants