Commit c95609bc by Mike Burns

Merge branch 'flush_writes-rewind' of https://github.com/jcantara/paperclip

parents 43a4f084 7cb73846
...@@ -77,6 +77,7 @@ module Paperclip ...@@ -77,6 +77,7 @@ module Paperclip
def flush_writes def flush_writes
for style, file in @queued_for_write do for style, file in @queued_for_write do
log("saving #{path(style)}") log("saving #{path(style)}")
file.rewind
retried = false retried = false
begin begin
directory.files.create(fog_file.merge( directory.files.create(fog_file.merge(
......
...@@ -281,6 +281,7 @@ module Paperclip ...@@ -281,6 +281,7 @@ module Paperclip
@queued_for_write.each do |style, file| @queued_for_write.each do |style, file|
begin begin
log("saving #{path(style)}") log("saving #{path(style)}")
file.rewind
acl = @s3_permissions[style] || @s3_permissions[:default] acl = @s3_permissions[style] || @s3_permissions[:default]
acl = acl.call(self, style) if acl.respond_to?(:call) acl = acl.call(self, style) if acl.respond_to?(:call)
write_options = { write_options = {
......
...@@ -115,7 +115,12 @@ class FogTest < Test::Unit::TestCase ...@@ -115,7 +115,12 @@ class FogTest < Test::Unit::TestCase
@dummy.avatar.to_file.seek(10) @dummy.avatar.to_file.seek(10)
assert_equal 0, @dummy.avatar.to_file.pos assert_equal 0, @dummy.avatar.to_file.pos
end end
should "rewind file in flush_writes" do
@dummy.avatar.queued_for_write.each { |style, file| file.expects(:rewind).with() }
@dummy.save
end
should "pass the content type to the Fog::Storage::AWS::Files instance" do should "pass the content type to the Fog::Storage::AWS::Files instance" do
Fog::Storage::AWS::Files.any_instance.expects(:create).with do |hash| Fog::Storage::AWS::Files.any_instance.expects(:create).with do |hash|
hash[:content_type] hash[:content_type]
......
...@@ -341,8 +341,14 @@ class S3Test < Test::Unit::TestCase ...@@ -341,8 +341,14 @@ class S3Test < Test::Unit::TestCase
@dummy.avatar.to_file.seek(10) @dummy.avatar.to_file.seek(10)
assert_equal 0, @dummy.avatar.to_file.pos assert_equal 0, @dummy.avatar.to_file.pos
end end
should "rewind file in flush_writes" do
@dummy.avatar.queued_for_write.each { |style, file| file.expects(:rewind).with() }
@dummy.save
end end
end
context "Generating a secure url with an expiration" do context "Generating a secure url with an expiration" do
setup do setup do
rebuild_model :storage => :s3, rebuild_model :storage => :s3,
......
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