Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
P
paranoia
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
paranoia
Commits
e7d075f1
Commit
e7d075f1
authored
Apr 08, 2014
by
Ryan Bigg
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Really only destroy associated records
parent
c9227381
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
1 deletions
+15
-1
lib/paranoia.rb
+4
-1
test/paranoia_test.rb
+11
-0
No files found.
lib/paranoia.rb
View file @
e7d075f1
...
...
@@ -135,7 +135,10 @@ class ActiveRecord::Base
end
if
dependent_reflections
.
any?
dependent_reflections
.
each
do
|
name
,
_
|
self
.
send
(
name
).
unscoped
.
each
(
&
:really_destroy!
)
associated_records
=
self
.
send
(
name
)
# Paranoid models will have this method, non-paranoid models will not
associated_records
=
associated_records
.
with_deleted
if
associated_records
.
respond_to?
(
:with_deleted
)
associated_records
.
each
(
&
:really_destroy!
)
end
end
destroy!
...
...
test/paranoia_test.rb
View file @
e7d075f1
...
...
@@ -309,6 +309,17 @@ class ParanoiaTest < test_framework
refute
RelatedModel
.
unscoped
.
exists?
(
child
.
id
)
end
def
test_real_destroy_dependent_destroy_after_normal_destroy_does_not_delete_other_children
parent_1
=
ParentModel
.
create
child_1
=
parent_1
.
very_related_models
.
create
parent_2
=
ParentModel
.
create
child_2
=
parent_2
.
very_related_models
.
create
parent_1
.
destroy
parent_1
.
really_destroy!
assert
RelatedModel
.
unscoped
.
exists?
(
child_2
.
id
)
end
if
ActiveRecord
::
VERSION
::
STRING
<
"4.1"
def
test_real_destroy
model
=
ParanoidModel
.
new
...
...
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