Skip to content
This repository
Browse code

Skip post processing on the size matcher

Fixes #646
  • Loading branch information...
commit 0efa3843164158df669497e6f12ce5a80ea368f1 1 parent c95609b
Prem Sichanugrist authored March 02, 2012
3  lib/paperclip/matchers/validate_attachment_size_matcher.rb
@@ -67,9 +67,12 @@ def passes_validation_with_size(new_size)
67 67
           override_method(file, :size){ new_size }
68 68
           override_method(file, :to_tempfile){ file }
69 69
 
  70
+          @subject.send(@attachment_name).post_processing = false
70 71
           @subject.send(@attachment_name).assign(file)
71 72
           @subject.valid?
72 73
           @subject.errors[:"#{@attachment_name}_file_size"].blank?
  74
+        ensure
  75
+          @subject.send(@attachment_name).post_processing = true
73 76
         end
74 77
 
75 78
         def lower_than_low?
14  test/matchers/validate_attachment_size_matcher_test.rb
@@ -68,5 +68,19 @@ class ValidateAttachmentSizeMatcherTest < Test::Unit::TestCase
68 68
         assert_rejects @matcher, @dummy
69 69
       end
70 70
     end
  71
+
  72
+    context "post processing" do
  73
+      setup do
  74
+        @dummy_class.validates_attachment_size :avatar, :greater_than => 1024
  75
+
  76
+        @dummy = @dummy_class.new
  77
+        @matcher = self.class.validate_attachment_size(:avatar).greater_than(1024)
  78
+      end
  79
+
  80
+      should "be skipped" do
  81
+        @dummy.avatar.expects(:post_process).never
  82
+        assert_accepts @matcher, @dummy
  83
+      end
  84
+    end
71 85
   end
72 86
 end

0 notes on commit 0efa384

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