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
06b190ca
Commit
06b190ca
authored
Sep 25, 2015
by
Leonardo Alifraco
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Touching record when restored.
parent
2b050e8d
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
0 deletions
+20
-0
lib/paranoia.rb
+1
-0
test/paranoia_test.rb
+19
-0
No files found.
lib/paranoia.rb
View file @
06b190ca
...
...
@@ -115,6 +115,7 @@ module Paranoia
if
(
noop_if_frozen
&&
!
@attributes
.
frozen?
)
||
!
noop_if_frozen
write_attribute
paranoia_column
,
paranoia_sentinel_value
update_columns
(
paranoia_restore_attributes
)
touch
end
restore_associated_records
if
opts
[
:recursive
]
end
...
...
test/paranoia_test.rb
View file @
06b190ca
...
...
@@ -20,6 +20,7 @@ def setup!
'paranoid_model_with_build_belongs'
=>
'parent_model_id INTEGER, deleted_at DATETIME, paranoid_model_with_has_one_and_build_id INTEGER, name VARCHAR(32)'
,
'paranoid_model_with_anthor_class_name_belongs'
=>
'parent_model_id INTEGER, deleted_at DATETIME, paranoid_model_with_has_one_id INTEGER'
,
'paranoid_model_with_foreign_key_belongs'
=>
'parent_model_id INTEGER, deleted_at DATETIME, has_one_foreign_key_id INTEGER'
,
'paranoid_model_with_timestamps'
=>
'parent_model_id INTEGER, created_at DATETIME, updated_at DATETIME, deleted_at DATETIME'
,
'not_paranoid_model_with_belongs'
=>
'parent_model_id INTEGER, paranoid_model_with_has_one_id INTEGER'
,
'paranoid_model_with_has_one_and_builds'
=>
'parent_model_id INTEGER, color VARCHAR(32), deleted_at DATETIME, has_one_foreign_key_id INTEGER'
,
'featureful_models'
=>
'deleted_at DATETIME, name VARCHAR(32)'
,
...
...
@@ -757,6 +758,19 @@ class ParanoiaTest < test_framework
refute
b
.
valid?
end
def
test_updated_at_modification_on_restore
parent1
=
ParentModel
.
create
pt1
=
ParanoidModelWithTimestamp
.
create
(
:parent_model
=>
parent1
)
ParanoidModelWithTimestamp
.
record_timestamps
=
false
pt1
.
update_columns
(
created_at:
20
.
years
.
ago
,
updated_at:
10
.
years
.
ago
,
deleted_at:
10
.
years
.
ago
)
ParanoidModelWithTimestamp
.
record_timestamps
=
true
assert
pt1
.
updated_at
<
10
.
minutes
.
ago
assert
!
pt1
.
deleted_at
.
nil?
pt1
.
restore!
assert
pt1
.
deleted_at
.
nil?
assert
pt1
.
updated_at
>
10
.
minutes
.
ago
end
def
test_i_am_the_destroyer
expected
=
%Q{
Sharon: "There should be a method called I_AM_THE_DESTROYER!"
...
...
@@ -1122,6 +1136,11 @@ class ParanoidModelWithForeignKeyBelong < ActiveRecord::Base
belongs_to
:paranoid_model_with_has_one
end
class
ParanoidModelWithTimestamp
<
ActiveRecord
::
Base
belongs_to
:parent_model
acts_as_paranoid
end
class
NotParanoidModelWithBelong
<
ActiveRecord
::
Base
belongs_to
:paranoid_model_with_has_one
end
...
...
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