Skip to content
This repository has been archived by the owner on Jul 13, 2023. It is now read-only.

Commit

Permalink
rewind files in flush_writes method of s3 and fog storage
Browse files Browse the repository at this point in the history
  • Loading branch information
Jesse Cantara committed Mar 1, 2012
1 parent 9e38958 commit 7cb7384
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 1 deletion.
1 change: 1 addition & 0 deletions lib/paperclip/storage/fog.rb
Expand Up @@ -77,6 +77,7 @@ def fog_public
def flush_writes
for style, file in @queued_for_write do
log("saving #{path(style)}")
file.rewind
retried = false
begin
directory.files.create(fog_file.merge(
Expand Down
1 change: 1 addition & 0 deletions lib/paperclip/storage/s3.rb
Expand Up @@ -281,6 +281,7 @@ def flush_writes #:nodoc:
@queued_for_write.each do |style, file|
begin
log("saving #{path(style)}")
file.rewind
acl = @s3_permissions[style] || @s3_permissions[:default]
acl = acl.call(self, style) if acl.respond_to?(:call)
write_options = {
Expand Down
7 changes: 6 additions & 1 deletion test/storage/fog_test.rb
Expand Up @@ -115,7 +115,12 @@ class FogTest < Test::Unit::TestCase
@dummy.avatar.to_file.seek(10)
assert_equal 0, @dummy.avatar.to_file.pos
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
Fog::Storage::AWS::Files.any_instance.expects(:create).with do |hash|
hash[:content_type]
Expand Down
6 changes: 6 additions & 0 deletions test/storage/s3_test.rb
Expand Up @@ -341,8 +341,14 @@ def counter
@dummy.avatar.to_file.seek(10)
assert_equal 0, @dummy.avatar.to_file.pos
end

should "rewind file in flush_writes" do
@dummy.avatar.queued_for_write.each { |style, file| file.expects(:rewind).with() }
@dummy.save
end

end

context "Generating a secure url with an expiration" do
setup do
rebuild_model :storage => :s3,
Expand Down

0 comments on commit 7cb7384

Please sign in to comment.