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
bd105ea6
Commit
bd105ea6
authored
Mar 13, 2014
by
ray
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add two test unit and could not pass
parent
f2c95e9a
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
41 additions
and
0 deletions
+41
-0
test/paranoia_test.rb
+41
-0
No files found.
test/paranoia_test.rb
View file @
bd105ea6
...
...
@@ -387,6 +387,47 @@ class ParanoiaTest < test_framework
assert
ParanoidModelWithBelong
.
with_deleted
.
reload
.
count
!=
0
,
"There should be a record"
end
def
test_new_restore_with_has_one_association
# setup and destroy test objects
hasOne
=
ParanoidModelWithHasOne
.
create
belongsTo
=
ParanoidModelWithBelong
.
create
hasOne
.
paranoid_model_with_belong
=
belongsTo
hasOne
.
save!
hasOne
.
destroy
assert_equal
false
,
hasOne
.
deleted_at
.
nil?
assert_equal
false
,
belongsTo
.
deleted_at
.
nil?
# Does it restore has_one associations?
newHasOne
=
ParanoidModelWithHasOne
.
with_deleted
.
find
(
hasOne
.
id
)
newHasOne
.
restore
(
:recursive
=>
true
)
newHasOne
.
save!
assert_equal
true
,
hasOne
.
reload
.
deleted_at
.
nil?
assert_equal
true
,
belongsTo
.
reload
.
deleted_at
.
nil?
,
"
#{
belongsTo
.
deleted_at
}
"
assert
ParanoidModelWithBelong
.
with_deleted
.
reload
.
count
!=
0
,
"There should be a record"
end
def
test_model_restore_with_has_one_association
# setup and destroy test objects
hasOne
=
ParanoidModelWithHasOne
.
create
belongsTo
=
ParanoidModelWithBelong
.
create
hasOne
.
paranoid_model_with_belong
=
belongsTo
hasOne
.
save!
hasOne
.
destroy
assert_equal
false
,
hasOne
.
deleted_at
.
nil?
assert_equal
false
,
belongsTo
.
deleted_at
.
nil?
# Does it restore has_one associations?
ParanoidModelWithHasOne
.
restore
(
hasOne
.
id
,
:recursive
=>
true
)
hasOne
.
save!
assert_equal
true
,
hasOne
.
reload
.
deleted_at
.
nil?
assert_equal
true
,
belongsTo
.
reload
.
deleted_at
.
nil?
,
"
#{
belongsTo
.
deleted_at
}
"
assert
ParanoidModelWithBelong
.
with_deleted
.
reload
.
count
!=
0
,
"There should be a record"
end
def
test_restore_with_nil_has_one_association
# setup and destroy test object
hasOne
=
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