Commit 054a807e by Prem Sichanugrist

Clear an attachment before save will now clear the attachment from write queue

Closes #62
parent 03560dc1
......@@ -167,6 +167,7 @@ module Paperclip
# use #destroy.
def clear
queue_existing_for_delete
@queued_for_write = {}
@errors = {}
end
......
......@@ -713,6 +713,15 @@ class AttachmentTest < Test::Unit::TestCase
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")
......
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