Commit ceab018b by Jon Yurek

Do not run post_processing if the attachment is not valid.

parent 17a03b28
...@@ -83,7 +83,7 @@ module Paperclip ...@@ -83,7 +83,7 @@ module Paperclip
@dirty = true @dirty = true
post_process post_process if valid?
# Reset the file size if the original file was reprocessed. # Reset the file size if the original file was reprocessed.
instance_write(:file_size, uploaded_file.size.to_i) instance_write(:file_size, uploaded_file.size.to_i)
......
...@@ -163,6 +163,7 @@ class AttachmentTest < Test::Unit::TestCase ...@@ -163,6 +163,7 @@ class AttachmentTest < Test::Unit::TestCase
@attachment.expects(:valid_assignment?).with(@not_file).returns(true) @attachment.expects(:valid_assignment?).with(@not_file).returns(true)
@attachment.expects(:queue_existing_for_delete) @attachment.expects(:queue_existing_for_delete)
@attachment.expects(:post_process) @attachment.expects(:post_process)
@attachment.expects(:valid?).returns(true)
@attachment.expects(:validate) @attachment.expects(:validate)
@dummy.avatar = @not_file @dummy.avatar = @not_file
end end
...@@ -192,6 +193,7 @@ class AttachmentTest < Test::Unit::TestCase ...@@ -192,6 +193,7 @@ class AttachmentTest < Test::Unit::TestCase
@attachment.expects(:valid_assignment?).with(@not_file).returns(true) @attachment.expects(:valid_assignment?).with(@not_file).returns(true)
@attachment.expects(:queue_existing_for_delete) @attachment.expects(:queue_existing_for_delete)
@attachment.expects(:post_process) @attachment.expects(:post_process)
@attachment.expects(:valid?).returns(true)
@attachment.expects(:validate) @attachment.expects(:validate)
@dummy.avatar = @not_file @dummy.avatar = @not_file
end end
......
...@@ -209,7 +209,7 @@ class IntegrationTest < Test::Unit::TestCase ...@@ -209,7 +209,7 @@ class IntegrationTest < Test::Unit::TestCase
@dummy.avatar = @bad_file @dummy.avatar = @bad_file
assert ! @dummy.valid? assert ! @dummy.valid?
@dummy.avatar = nil @dummy.avatar = nil
assert @dummy.valid? assert @dummy.valid?, @dummy.errors.inspect
end end
should "know the difference between good files, bad files, not files, and nil when validating" do should "know the difference between good files, bad files, not files, and nil when validating" do
......
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