Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Skip post processing on the size matcher

Fixes #646
  • Loading branch information...
commit 0efa3843164158df669497e6f12ce5a80ea368f1 1 parent c95609b
Prem Sichanugrist sikachu authored
3  lib/paperclip/matchers/validate_attachment_size_matcher.rb
View
@@ -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?
14 test/matchers/validate_attachment_size_matcher_test.rb
View
@@ -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
Please sign in to comment.
Something went wrong with that request. Please try again.