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
ed86d01c
Unverified
Commit
ed86d01c
authored
Jun 29, 2020
by
Rebecca Le
Committed by
GitHub
Jun 29, 2020
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #482 from hashwin/hashwin/after_commit
Fix after_commit for Rails 6
parents
0600183a
5b6be565
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
0 deletions
+20
-0
lib/paranoia.rb
+5
-0
test/paranoia_test.rb
+15
-0
No files found.
lib/paranoia.rb
View file @
ed86d01c
...
@@ -69,6 +69,7 @@ module Paranoia
...
@@ -69,6 +69,7 @@ module Paranoia
next
unless
send
(
association
.
reflection
.
name
)
next
unless
send
(
association
.
reflection
.
name
)
association
.
decrement_counters
association
.
decrement_counters
end
end
@_trigger_destroy_callback
=
true
@_disable_counter_cache
=
false
@_disable_counter_cache
=
false
result
result
end
end
...
@@ -81,6 +82,10 @@ module Paranoia
...
@@ -81,6 +82,10 @@ module Paranoia
raise
(
ActiveRecord
::
RecordNotDestroyed
.
new
(
"Failed to destroy the record"
,
self
))
raise
(
ActiveRecord
::
RecordNotDestroyed
.
new
(
"Failed to destroy the record"
,
self
))
end
end
def
trigger_transactional_callbacks?
super
||
@_trigger_destroy_callback
&&
paranoia_destroyed?
end
def
paranoia_delete
def
paranoia_delete
raise
ActiveRecord
::
ReadOnlyRecord
,
"
#{
self
.
class
}
is marked as readonly"
if
readonly?
raise
ActiveRecord
::
ReadOnlyRecord
,
"
#{
self
.
class
}
is marked as readonly"
if
readonly?
if
persisted?
if
persisted?
...
...
test/paranoia_test.rb
View file @
ed86d01c
...
@@ -131,6 +131,21 @@ class ParanoiaTest < test_framework
...
@@ -131,6 +131,21 @@ class ParanoiaTest < test_framework
assert
model
.
instance_variable_get
(
:@after_commit_callback_called
)
assert
model
.
instance_variable_get
(
:@after_commit_callback_called
)
end
end
def
test_destroy_behavior_for_freshly_loaded_plain_models_callbacks
model
=
CallbackModel
.
new
model
.
save
model
=
CallbackModel
.
find
(
model
.
id
)
model
.
destroy
assert_nil
model
.
instance_variable_get
(
:@update_callback_called
)
assert_nil
model
.
instance_variable_get
(
:@save_callback_called
)
assert_nil
model
.
instance_variable_get
(
:@validate_called
)
assert
model
.
instance_variable_get
(
:@destroy_callback_called
)
assert
model
.
instance_variable_get
(
:@after_destroy_callback_called
)
assert
model
.
instance_variable_get
(
:@after_commit_callback_called
)
end
def
test_delete_behavior_for_plain_models_callbacks
def
test_delete_behavior_for_plain_models_callbacks
model
=
CallbackModel
.
new
model
=
CallbackModel
.
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