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

Rewind file in Storage::Fog if bucket does not exist #2572

Merged
merged 1 commit into from
Mar 9, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions lib/paperclip/storage/fog.rb
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ def flush_writes
raise if retried
retried = true
directory.save
file.rewind
retry
ensure
file.rewind
Expand Down
5 changes: 5 additions & 0 deletions spec/paperclip/storage/fog_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,11 @@ def custom_method
assert @dummy.save
assert @connection.directories.get(@fog_directory)
end

it "sucessfully rewinds the file during bucket creation" do
assert @dummy.save
expect(Paperclip.io_adapters.for(@dummy.avatar).read.length).to be > 0
end
end

context "with a bucket" do
Expand Down