Skip to content

Commit

Permalink
We can't File.exist?(UploadedFile).
Browse files Browse the repository at this point in the history
When trying to check if a ActionDispatch::Http::UploadedFile we need to
explicitly call #path on it to make it work.
  • Loading branch information
Manfred committed Jun 3, 2014
1 parent 7cc67c5 commit 5645575
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
4 changes: 4 additions & 0 deletions lib/attachment_san/test/helper.rb
Expand Up @@ -69,6 +69,10 @@ def path #:nodoc:
@tempfile.path
end

def to_s
raise TypeError, "no implicit conversion of AttachmentSan::UploadHelpers::FakeUploadFile into String"
end

alias local_path path

def method_missing(method_name, *args, &block) #:nodoc:
Expand Down
2 changes: 1 addition & 1 deletion lib/attachment_san/variant.rb
Expand Up @@ -411,7 +411,7 @@ def filename
# Returns true when there is an uploaded file on disk.
#
def has_upload?
@record.uploaded_file && File.exist?(@record.uploaded_file)
@record.uploaded_file && File.exist?(@record.uploaded_file.path)
end

##
Expand Down

0 comments on commit 5645575

Please sign in to comment.