Commit d46a1afe by Prem Sichanugrist

Rewind tempfiles after get saved to storages

Re-fix of #838, #766, #911
parent cdf85a20
......@@ -90,6 +90,8 @@ module Paperclip
retried = true
directory.save
retry
ensure
file.rewind
end
end
......
......@@ -310,6 +310,8 @@ module Paperclip
rescue AWS::S3::Errors::NoSuchBucket => e
create_bucket
retry
ensure
file.rewind
end
end
......
......@@ -111,6 +111,12 @@ class FogTest < Test::Unit::TestCase
directory.destroy
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
should "pass the content type to the Fog::Storage::AWS::Files instance" do
Fog::Storage::AWS::Files.any_instance.expects(:create).with do |hash|
hash[:content_type]
......
......@@ -569,6 +569,12 @@ class S3Test < Test::Unit::TestCase
assert_match %r{^http://s3\.amazonaws\.com/testing/avatars/original/5k\.png}, @dummy.avatar.url
end
should "be rewinded after flush_writes" do
files = @dummy.avatar.queued_for_write.map{ |style, file| file.tap(&:read) }
@dummy.save
assert files.none?(&:eof?), "Expect all the files to be rewinded."
end
context "and saved" do
setup do
object = stub
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment