Commit 0238e681 by Jonah Williams Committed by Jon Yurek

filename returns basename when no extension present

parent e703662f
......@@ -35,7 +35,7 @@ module Paperclip
# Returns the filename, the same way as ":basename.:extension" would.
def filename attachment, style_name
"#{basename(attachment, style_name)}.#{extension(attachment, style_name)}"
(ext = extension(attachment, style_name)).blank? ? basename(attachment, style_name) : "#{basename(attachment, style_name)}.#{ext}"
end
# Returns the interpolated URL. Will raise an error if the url itself
......
......@@ -110,6 +110,13 @@ class InterpolationsTest < Test::Unit::TestCase
assert_equal "one.png", Paperclip::Interpolations.filename(attachment, :style)
end
should "return the filename as basename when extension is blank" do
attachment = mock
attachment.stubs(:styles).returns({})
attachment.stubs(:original_filename).returns("one")
assert_equal "one", Paperclip::Interpolations.filename(attachment, :style)
end
should "return the timestamp" do
now = Time.now
zone = 'UTC'
......
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