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
486e42ec
Commit
486e42ec
authored
Nov 28, 2014
by
John Hawthorn
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Slightly more readable spec
Change-Id: Ib73e43a5adcb8bd9b5bbf5b7ca60f9865e5415e7
parent
c8a943a6
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
8 deletions
+11
-8
test/paranoia_test.rb
+11
-8
No files found.
test/paranoia_test.rb
View file @
486e42ec
...
@@ -543,18 +543,21 @@ class ParanoiaTest < test_framework
...
@@ -543,18 +543,21 @@ class ParanoiaTest < test_framework
def
test_restoring_recursive_has_one_restores_correct_object
def
test_restoring_recursive_has_one_restores_correct_object
hasOnes
=
2
.
times
.
map
{
ParanoidModelWithHasOne
.
create
}
hasOnes
=
2
.
times
.
map
{
ParanoidModelWithHasOne
.
create
}
belongsTos
=
2
.
times
.
map
{
ParanoidModelWithBelong
.
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
}
hasOnes
[
0
].
update
paranoid_model_with_belong:
belongsTos
[
0
]
hasOnes
[
1
].
update
paranoid_model_with_belong:
belongsTos
[
1
]
hasOnes
.
each
(
&
:destroy
)
ParanoidModelWithHasOne
.
restore
(
hasOnes
[
1
],
:recursive
=>
true
)
ParanoidModelWithHasOne
.
restore
(
hasOnes
[
1
],
:recursive
=>
true
)
hasOnes
.
each
{
|
ho
|
ho
.
reload
}
hasOnes
.
each
(
&
:reload
)
belongsTos
.
each
{
|
bt
|
bt
.
reload
}
belongsTos
.
each
(
&
:reload
)
# without #185, belongsTos[0] will be restored instead of belongsTos[1]
# without #185, belongsTos[0] will be restored instead of belongsTos[1]
assert_equal
false
,
hasOnes
[
0
].
deleted_at
.
nil?
refute_nil
hasOnes
[
0
].
deleted_at
assert_equal
false
,
belongsTos
[
0
].
deleted_at
.
nil?
refute_nil
belongsTos
[
0
].
deleted_at
assert_
equal
true
,
hasOnes
[
1
].
deleted_at
.
nil?
assert_
nil
hasOnes
[
1
].
deleted_at
assert_
equal
true
,
belongsTos
[
1
].
deleted_at
.
nil?
assert_
nil
belongsTos
[
1
].
deleted_at
end
end
# covers #131
# covers #131
...
...
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