Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Clear an attachment before save will now clear the attachment from wr…

…ite queue

Closes #62
  • Loading branch information...
commit 054a807eeb40dc792070db5d07e7aab1af269093 1 parent 03560dc
@sikachu sikachu authored
Showing with 10 additions and 0 deletions.
  1. +1 −0  lib/paperclip/attachment.rb
  2. +9 −0 test/attachment_test.rb
View
1  lib/paperclip/attachment.rb
@@ -167,6 +167,7 @@ def save
# use #destroy.
def clear
queue_existing_for_delete
+ @queued_for_write = {}
@errors = {}
end
View
9 test/attachment_test.rb
@@ -713,6 +713,15 @@ def do_after_all; end
assert_equal nil, @attachment.path(:blah)
end
+ context "with a file assigned but not saved yet" do
+ should "clear out any attached files" do
+ @attachment.assign(@file)
+ assert !@attachment.queued_for_write.blank?
+ @attachment.clear
+ assert @attachment.queued_for_write.blank?
+ end
+ end
+
context "with a file assigned in the database" do
setup do
@attachment.stubs(:instance_read).with(:file_name).returns("5k.png")
Please sign in to comment.
Something went wrong with that request. Please try again.