Commit 1fcf1d7e by Mark Van Holstyn

Fixed bug when exists? called and original_filename is nil

parent 465fba83
...@@ -6,7 +6,11 @@ module Paperclip ...@@ -6,7 +6,11 @@ module Paperclip
end end
def exists?(style = default_style) def exists?(style = default_style)
File.exist?(path(style)) if original_filename
File.exist?(path(style))
else
false
end
end end
# Returns representation of the data of the file assigned to the given # Returns representation of the data of the file assigned to the given
......
...@@ -28,6 +28,16 @@ class AttachmentTest < Test::Unit::TestCase ...@@ -28,6 +28,16 @@ class AttachmentTest < Test::Unit::TestCase
end end
end end
context "without an Attachment" do
setup do
@dummy = Dummy.new
end
should "return false when asked exists?" do
assert !@dummy.avatar.exists?
end
end
context "on an Attachment" do context "on an Attachment" do
setup do setup do
@dummy = Dummy.new @dummy = Dummy.new
......
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