README.md in paperclip-storage-tmp-0.0.2 vs README.md in paperclip-storage-tmp-0.0.3
- old
+ new
@@ -1,7 +1,9 @@
# paperclip-storage-tmp
+[![Build Status](https://secure.travis-ci.org/exviva/paperclip-storage-tmp.png?branch=master)](http://travis-ci.org/exviva/paperclip-storage-tmp)
+
This gem allows you to configure Paperclip 2.x to use your temporary directory to store the attachments. The attachments are deleted as soon as your Ruby process exits, or whenever you ask the gem to delete them (e.g. after every test), ensuring isolated state for each test.
Thanks to this gem your `public/system` directory is no longer cluttered with attachments dangling in there after your test suite has finished running.
It also prevents the attachments created by tests from conflicting with attachments uploaded in development. Storing the images using the default, `filesystem` storage both in development and test environments may lead to false positives and other unexpected behaviour in your tests.
@@ -26,11 +28,11 @@
Just like you wouldn't want to use the same database in development and test, you probably don't want to use the same storage directory (which also is a kind of a database).
## Compatibility with Paperclip versions
-Please note that this gem has been written with Paperclip 2.x in mind (extracted from and battle-tested in an application dependent on Paperclip 2.4.0). The gemspec declares a rather loose dependency on Paperclip of '~> 2.0', so make sure the gem is behaving as expected. Since it's supposed to be used only in test environment, it shouldn't be harmful to just give it a try. If you confirm that it's working for the version of Paperclip you're using, let me know.
+Please note that this gem has been written with Paperclip 2.x in mind (extracted from and battle-tested in an application dependent on Paperclip 2.4.0, then upgraded to 2.7.0). The gemspec declares a rather loose dependency on Paperclip of '~> 2.4', '>= 2.4.2', so make sure the gem is behaving as expected. Since it's supposed to be used only in test environment, it shouldn't be harmful to just give it a try. If you confirm that it's working for the version of Paperclip you're using, let me know.
Any pull requests increasing compatibility with other versions welcome!
## Installation
@@ -90,16 +92,14 @@
# in features/support/env.rb
require 'paperclip-storage-tmp/testing/cucumber'
## Caveats
-Beware that the file name assigned to the model attribute (`<attachment>_file_name`) is different than the name of the assigned/uploaded file (it's the name of the temporary file - a unique string).
+Beware that Paperclip doesn't know that the file doesn't physically exist in `public/system`, so you can't use `Attachment#path` to access the physical file. You can use `attachment.to_file.path` to find the actual location of the attachment on disk.
-Also, Paperclip doesn't know that the file doesn't physically exist in `public/system`, so you can't use `Attachment#path` to access the physical file. You can use `attachment.to_file.path` to find the actual location of the attachment on disk.
+Here are a couple of specs, which expose the expected behaviour of this gem. The spec markes with `# FAIL` exposes the caveat:
-Here are a couple of specs, which expose the expected behaviour of this gem. The specs markes with `# FAIL` expose the caveats:
-
describe User do
describe 'avatar' do
let(:user) { User.create!(avatar: File.new('spec/fixtures/hey_mom_its_me.png')) }
subject { user.avatar }
@@ -139,13 +139,12 @@
it 'can persist assignment from File' do
new_user = User.create!(avatar: avatar_file)
new_user.reload.avatar_file_name.should eq('hey_mom_its_me.png')
end
- # :(
- it 'cannot handle assignment from Paperclip::Attachment' do
+ it 'can handle assignment from Paperclip::Attachment' do
new_user = User.new(avatar: subject)
- new_user.avatar_file_name.should_not eq('hey_mom_its_me.png') # FAIL
+ new_user.avatar_file_name.should eq('hey_mom_its_me.png')
end
end
end
## Contributing