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
d8592ae2
Commit
d8592ae2
authored
Jan 21, 2015
by
John Hawthorn
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Raise when destroying read only record
parent
56e0f47e
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
0 deletions
+17
-0
lib/paranoia.rb
+1
-0
test/paranoia_test.rb
+16
-0
No files found.
lib/paranoia.rb
View file @
d8592ae2
...
...
@@ -107,6 +107,7 @@ module Paranoia
# insert time to paranoia column.
# @param with_transaction [Boolean] exec with ActiveRecord Transactions.
def
touch_paranoia_column
(
with_transaction
=
false
)
raise
ActiveRecord
::
ReadOnlyRecord
,
"
#{
self
.
class
}
is marked as readonly"
if
readonly?
return
self
if
really_destroyed?
||
new_record?
# This method is (potentially) called from really_destroy
...
...
test/paranoia_test.rb
View file @
d8592ae2
...
...
@@ -291,6 +291,22 @@ class ParanoiaTest < test_framework
assert
model
.
instance_variable_get
(
:@destroy_callback_called
)
end
def
test_destroy_on_readonly_record
# Just to demonstrate the AR behaviour
model
=
NonParanoidModel
.
create!
model
.
readonly!
assert_raises
ActiveRecord
::
ReadOnlyRecord
do
model
.
destroy
end
# Mirrors behaviour above
model
=
ParanoidModel
.
create!
model
.
readonly!
assert_raises
ActiveRecord
::
ReadOnlyRecord
do
model
.
destroy
end
end
def
test_restore
model
=
ParanoidModel
.
new
model
.
save
...
...
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