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
26b9f4f7
Commit
26b9f4f7
authored
Sep 12, 2013
by
Ryan Bigg
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #69 from fullcirclegroup/class-level-restore
Add Model#restore(id)
parents
95f6a5d6
4ff0fdad
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
36 additions
and
1 deletions
+36
-1
lib/paranoia.rb
+8
-0
test/paranoia_test.rb
+28
-1
No files found.
lib/paranoia.rb
View file @
26b9f4f7
...
...
@@ -13,6 +13,14 @@ module Paranoia
def
with_deleted
all
.
tap
{
|
x
|
x
.
default_scoped
=
false
}
end
def
restore
(
id
)
if
id
.
is_a?
(
Array
)
id
.
map
{
|
one_id
|
restore
(
one_id
)
}
else
only_deleted
.
find
(
id
).
restore!
end
end
end
def
destroy
...
...
test/paranoia_test.rb
View file @
26b9f4f7
...
...
@@ -71,7 +71,7 @@ class ParanoiaTest < Test::Unit::TestCase
assert_equal
0
,
model
.
class
.
count
assert_equal
1
,
model
.
class
.
unscoped
.
count
end
def
test_scoping_behavior_for_paranoid_models
ParanoidModel
.
unscoped
.
delete_all
parent1
=
ParentModel
.
create
...
...
@@ -204,6 +204,33 @@ class ParanoiaTest < Test::Unit::TestCase
refute
ParanoidModel
.
unscoped
.
exists?
(
model
.
id
)
end
def
test_multiple_restore
a
=
ParanoidModel
.
new
a
.
save
a_id
=
a
.
id
a
.
destroy
b
=
ParanoidModel
.
new
b
.
save
b_id
=
b
.
id
b
.
destroy
c
=
ParanoidModel
.
new
c
.
save
c_id
=
c
.
id
c
.
destroy
ParanoidModel
.
restore
([
a_id
,
c_id
])
a
.
reload
b
.
reload
c
.
reload
refute
a
.
destroyed?
assert
b
.
destroyed?
refute
c
.
destroyed?
end
private
def
get_featureful_model
FeaturefulModel
.
new
(
:name
=>
"not empty"
)
...
...
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