Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
P
paperclip
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
ikcrm_common
paperclip
Commits
054a807e
Commit
054a807e
authored
Jun 30, 2011
by
Prem Sichanugrist
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Clear an attachment before save will now clear the attachment from write queue
Closes #62
parent
03560dc1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
10 additions
and
0 deletions
+10
-0
lib/paperclip/attachment.rb
+1
-0
test/attachment_test.rb
+9
-0
No files found.
lib/paperclip/attachment.rb
View file @
054a807e
...
@@ -167,6 +167,7 @@ module Paperclip
...
@@ -167,6 +167,7 @@ module Paperclip
# use #destroy.
# use #destroy.
def
clear
def
clear
queue_existing_for_delete
queue_existing_for_delete
@queued_for_write
=
{}
@errors
=
{}
@errors
=
{}
end
end
...
...
test/attachment_test.rb
View file @
054a807e
...
@@ -713,6 +713,15 @@ class AttachmentTest < Test::Unit::TestCase
...
@@ -713,6 +713,15 @@ class AttachmentTest < Test::Unit::TestCase
assert_equal
nil
,
@attachment
.
path
(
:blah
)
assert_equal
nil
,
@attachment
.
path
(
:blah
)
end
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
context
"with a file assigned in the database"
do
setup
do
setup
do
@attachment
.
stubs
(
:instance_read
).
with
(
:file_name
).
returns
(
"5k.png"
)
@attachment
.
stubs
(
:instance_read
).
with
(
:file_name
).
returns
(
"5k.png"
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment