For anyone who might stumble upon the following problem:
In my unit test, I’m checking if the deletion of a Paperclip attachment
my model actually works. However, when I call Object.save, my file is
deleted from disk! You don’t want this to happen in a test environment.
Inspired by some ideas on the interwebz, (specifically on the Stack
site) I created this monkey patch.
-- encoding : utf-8 --
Only in test mode do we prevent Paperclip from deleting attachments on
Then add this line at the top of any test file that deleted attachments:
Now, when your attachments are deleted, the file they point to is not
deleted by Paperclip.
All the best,