Created
June 18, 2014 17:43
-
-
Save djcp/e5569155b402fd62d837 to your computer and use it in GitHub Desktop.
Monkeypatch paperclip for fast processing during specs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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