Skip to content

Instantly share code, notes, and snippets.

@metaskills
Created November 23, 2009 17:13
Show Gist options
  • Save metaskills/241203 to your computer and use it in GitHub Desktop.
Save metaskills/241203 to your computer and use it in GitHub Desktop.
From d6e50913039d93d5a55daf3e952c79c839f9cdca Mon Sep 17 00:00:00 2001
From: Ken Collins <[email protected]>
Date: Mon, 23 Nov 2009 11:44:23 -0500
Subject: [PATCH] Allow :processors => false option to no op any processor actions.
---
lib/paperclip/attachment.rb | 2 +-
test/attachment_test.rb | 19 +++++++++++++++++++
2 files changed, 20 insertions(+), 1 deletions(-)
diff --git a/lib/paperclip/attachment.rb b/lib/paperclip/attachment.rb
index b359105..13c6bbe 100644
--- a/lib/paperclip/attachment.rb
+++ b/lib/paperclip/attachment.rb
@@ -41,7 +41,7 @@ module Paperclip
@storage = options[:storage]
@whiny = options[:whiny_thumbnails] || options[:whiny]
@convert_options = options[:convert_options] || {}
- @processors = options[:processors] || [:thumbnail]
+ @processors = options[:processors].is_a?(FalseClass) ? false : (options[:processors] || [:thumbnail])
@options = options
@queued_for_delete = []
@queued_for_write = {}
diff --git a/test/attachment_test.rb b/test/attachment_test.rb
index d1e1737..b1c80ed 100644
--- a/test/attachment_test.rb
+++ b/test/attachment_test.rb
@@ -376,6 +376,25 @@ class AttachmentTest < Test::Unit::TestCase
assert_raises(RuntimeError){ @dummy.avatar = @file }
end
end
+
+ context "An attachment with false processors defined" do
+ setup do
+ rebuild_model :processors => false
+ @dummy = Dummy.new
+ @file = StringIO.new("...")
+ end
+ should "not raise when assigned to and saved" do
+ assert_nothing_raised() do
+ @dummy.avatar = @file
+ @dummy.save
+ end
+ end
+ should 'not use any processors' do
+ Paperclip::Processor.expects(:make).never
+ @dummy.avatar = @file
+ @dummy.save
+ end
+ end
context "Assigning an attachment with post_process hooks" do
setup do
--
1.6.4.2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment