Changing the path for integration tests in a paper clip application

The documentation for Paperclip mentions that you can change the download path for tests by placing the following code in the test.rb environment test.rb :

 Paperclip::Attachment.default_options[:path] = "#{Rails.root}/spec/test_files/:class/:id_partition/:style.:extension" 

The problem I am facing is that the application has a path set in the model that is not overwritten:

 has_attached_file :photo, path: ':attachment/:id/:style.:extension' 

When I run the tests, the files are uploaded to the /photo/ folder instead of /spec/test_files/ .

I can probably achieve this by writing a custom Paperclip adapter, but there should be an easier way.

+5
source share

All Articles