Skip to content

Commit

Permalink
Also make sure that file is rewinded in filestore
Browse files Browse the repository at this point in the history
  • Loading branch information
sikachu committed Jun 15, 2012
1 parent 95d7c4a commit e5ed019
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/paperclip/storage/filesystem.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ def flush_writes #:nodoc:
end
end
FileUtils.chmod(0666&~File.umask, path(style_name))
file.rewind
end

after_flush_writes # allows attachment to clean up temp files
Expand Down
6 changes: 6 additions & 0 deletions test/storage/filesystem_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,12 @@ class FileSystemTest < Test::Unit::TestCase
@dummy.save
assert_file_exists(@dummy.avatar.path(:thumbnail))
end

should "be rewinded after flush_writes" do
files = @dummy.avatar.queued_for_write.map{ |style, file| file }
@dummy.save
assert files.none?(&:eof?), "Expect all the files to be rewinded."
end
end

context "with file that has space in file name" do
Expand Down

0 comments on commit e5ed019

Please sign in to comment.