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
c8a943a6
Commit
c8a943a6
authored
Nov 27, 2014
by
Martin Sereinig
Committed by
John Hawthorn
Nov 28, 2014
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
test for issue #185
parent
ec04c682
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
1 deletions
+19
-1
test/paranoia_test.rb
+19
-1
No files found.
test/paranoia_test.rb
View file @
c8a943a6
...
@@ -538,7 +538,25 @@ class ParanoiaTest < test_framework
...
@@ -538,7 +538,25 @@ class ParanoiaTest < test_framework
assert
hasOne
.
reload
.
deleted_at
.
nil?
assert
hasOne
.
reload
.
deleted_at
.
nil?
end
end
# covers #185
def
test_restoring_recursive_has_one_restores_correct_object
hasOnes
=
2
.
times
.
map
{
ParanoidModelWithHasOne
.
create
}
belongsTos
=
2
.
times
.
map
{
ParanoidModelWithBelong
.
create
}
hasOnes
.
each_with_index
{
|
ho
,
i
|
ho
.
update
paranoid_model_with_belong:
belongsTos
[
i
]
}
hasOnes
.
each
{
|
ho
|
ho
.
destroy
}
ParanoidModelWithHasOne
.
restore
(
hasOnes
[
1
],
:recursive
=>
true
)
hasOnes
.
each
{
|
ho
|
ho
.
reload
}
belongsTos
.
each
{
|
bt
|
bt
.
reload
}
# without #185, belongsTos[0] will be restored instead of belongsTos[1]
assert_equal
false
,
hasOnes
[
0
].
deleted_at
.
nil?
assert_equal
false
,
belongsTos
[
0
].
deleted_at
.
nil?
assert_equal
true
,
hasOnes
[
1
].
deleted_at
.
nil?
assert_equal
true
,
belongsTos
[
1
].
deleted_at
.
nil?
end
# covers #131
# covers #131
def
test_has_one_really_destroy_with_nil
def
test_has_one_really_destroy_with_nil
model
=
ParanoidModelWithHasOne
.
create
model
=
ParanoidModelWithHasOne
.
create
...
...
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