Skip to content

Instantly share code, notes, and snippets.

@djcp
Created June 18, 2014 17:43
Show Gist options
  • Save djcp/e5569155b402fd62d837 to your computer and use it in GitHub Desktop.
Save djcp/e5569155b402fd62d837 to your computer and use it in GitHub Desktop.
Monkeypatch paperclip for fast processing during specs
module ImageHelpers
def fixture_file(path)
File.open(path)
end
end
module Paperclip
class Geometry
def self.from_file file
parse("100x100")
end
end
class FileCommandContentTypeDetector
def detect
'image/jpg'
end
end
class MediaTypeSpoofDetector
def spoofed?
false
end
end
class Thumbnail
include ImageHelpers
def make
src = fixture_file('photo.jpg')
dst = Tempfile.new([@basename, @format].compact.join("."))
dst.binmode
FileUtils.cp(src.path, dst.path)
return dst
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment