Skip to content
View
3 lib/paperclip/matchers/validate_attachment_size_matcher.rb
@@ -67,9 +67,12 @@ def passes_validation_with_size(new_size)
override_method(file, :size){ new_size }
override_method(file, :to_tempfile){ file }
+ @subject.send(@attachment_name).post_processing = false
@subject.send(@attachment_name).assign(file)
@subject.valid?
@subject.errors[:"#{@attachment_name}_file_size"].blank?
+ ensure
+ @subject.send(@attachment_name).post_processing = true
end
def lower_than_low?
View
14 test/matchers/validate_attachment_size_matcher_test.rb
@@ -68,5 +68,19 @@ class ValidateAttachmentSizeMatcherTest < Test::Unit::TestCase
assert_rejects @matcher, @dummy
end
end
+
+ context "post processing" do
+ setup do
+ @dummy_class.validates_attachment_size :avatar, :greater_than => 1024
+
+ @dummy = @dummy_class.new
+ @matcher = self.class.validate_attachment_size(:avatar).greater_than(1024)
+ end
+
+ should "be skipped" do
+ @dummy.avatar.expects(:post_process).never
+ assert_accepts @matcher, @dummy
+ end
+ end
end
end

0 comments on commit 0efa384

Please sign in to comment.
Something went wrong with that request. Please try again.