Commit 0efa3843 by Prem Sichanugrist

Skip post processing on the size matcher

Fixes #646
parent c95609bc
...@@ -67,9 +67,12 @@ module Paperclip ...@@ -67,9 +67,12 @@ module Paperclip
override_method(file, :size){ new_size } override_method(file, :size){ new_size }
override_method(file, :to_tempfile){ file } override_method(file, :to_tempfile){ file }
@subject.send(@attachment_name).post_processing = false
@subject.send(@attachment_name).assign(file) @subject.send(@attachment_name).assign(file)
@subject.valid? @subject.valid?
@subject.errors[:"#{@attachment_name}_file_size"].blank? @subject.errors[:"#{@attachment_name}_file_size"].blank?
ensure
@subject.send(@attachment_name).post_processing = true
end end
def lower_than_low? def lower_than_low?
......
...@@ -68,5 +68,19 @@ class ValidateAttachmentSizeMatcherTest < Test::Unit::TestCase ...@@ -68,5 +68,19 @@ class ValidateAttachmentSizeMatcherTest < Test::Unit::TestCase
assert_rejects @matcher, @dummy assert_rejects @matcher, @dummy
end end
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
end end
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment