Skip to content
This repository has been archived by the owner on Dec 29, 2021. It is now read-only.

Commit

Permalink
Fixes a stupid bit of name generation.
Browse files Browse the repository at this point in the history
  • Loading branch information
Jon Yurek committed Oct 26, 2010
1 parent 8fdf01a commit 1d77573
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/paperclip/storage/s3.rb
Expand Up @@ -127,10 +127,10 @@ def s3_protocol
# style, in the format most representative of the current storage.
def to_file style = default_style
return @queued_for_write[style] if @queued_for_write[style]
filename = path(style).split(".")
filename = path(style)
extname = File.extname(filename)
basename = File.basename(filename, extname)
file = Tempfile.new(basename, extname)
file = Tempfile.new([basename, extname])
file.write(AWS::S3::S3Object.value(path(style), bucket_name))
file.rewind
return file
Expand Down
5 changes: 5 additions & 0 deletions test/storage_test.rb
Expand Up @@ -351,6 +351,11 @@ class AWS::S3::NoSuchBucket < AWS::S3::ResponseError
should "be on S3" do
assert true
end

should "generate a tempfile with the right name" do
file = @dummy.avatar.to_file
assert_match /^original.*\.png$/, File.basename(file.path)
end
end
end
end
Expand Down

0 comments on commit 1d77573

Please sign in to comment.