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
a01677f5
Commit
a01677f5
authored
Oct 28, 2013
by
Krzysiek
Committed by
Jon Yurek
Nov 01, 2013
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Prevent file deletion on transaction rollback
parent
3367a541
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
13 additions
and
4 deletions
+13
-4
lib/paperclip/has_attached_file.rb
+1
-1
test/attachment_test.rb
+9
-0
test/has_attached_file_test.rb
+3
-3
No files found.
lib/paperclip/has_attached_file.rb
View file @
a01677f5
...
...
@@ -81,7 +81,7 @@ module Paperclip
name
=
@name
@klass
.
send
(
:after_save
)
{
send
(
name
).
send
(
:save
)
}
@klass
.
send
(
:before_destroy
)
{
send
(
name
).
send
(
:queue_all_for_delete
)
}
@klass
.
send
(
:after_destroy
)
{
send
(
name
).
send
(
:flush_deletes
)
}
@klass
.
send
(
:after_
commit
,
:on
=>
:
destroy
)
{
send
(
name
).
send
(
:flush_deletes
)
}
end
def
add_paperclip_callbacks
...
...
test/attachment_test.rb
View file @
a01677f5
...
...
@@ -1419,6 +1419,15 @@ class AttachmentTest < Test::Unit::TestCase
@dummy
.
destroy
assert_file_not_exists
(
@path
)
end
should
"not be deleted when transaction rollbacks after model is destroyed"
do
ActiveRecord
::
Base
.
transaction
do
@dummy
.
destroy
raise
ActiveRecord
::
Rollback
end
assert_file_exists
(
@path
)
end
end
end
test/has_attached_file_test.rb
View file @
a01677f5
...
...
@@ -35,8 +35,8 @@ class HasAttachedFileTest < Test::Unit::TestCase
assert_adding_attachment
(
'avatar'
).
defines_callback
(
'before_destroy'
)
end
should
'define an after_
destroy
callback'
do
assert_adding_attachment
(
'avatar'
).
defines_callback
(
'after_
destroy
'
)
should
'define an after_
commit
callback'
do
assert_adding_attachment
(
'avatar'
).
defines_callback
(
'after_
commit
'
)
end
should
'define the Paperclip-specific callbacks'
do
...
...
@@ -116,7 +116,7 @@ class HasAttachedFileTest < Test::Unit::TestCase
define_method:
nil
,
after_save:
nil
,
before_destroy:
nil
,
after_
destroy
:
nil
,
after_
commit
:
nil
,
define_paperclip_callbacks:
nil
,
extend:
nil
,
name:
'Billy'
)
...
...
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