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
c117d04e
Commit
c117d04e
authored
Mar 07, 2017
by
edwardmp
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add test for validator
parent
8be4fcb7
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
0 deletions
+19
-0
test/paranoia_test.rb
+19
-0
No files found.
test/paranoia_test.rb
View file @
c117d04e
...
@@ -21,6 +21,7 @@ def setup!
...
@@ -21,6 +21,7 @@ def setup!
'paranoid_model_with_foreign_key_belongs'
=>
'parent_model_id INTEGER, deleted_at DATETIME, has_one_foreign_key_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'
,
'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'
,
'not_paranoid_model_with_belongs'
=>
'parent_model_id INTEGER, paranoid_model_with_has_one_id INTEGER'
,
'not_paranoid_model_with_belongs_and_assocation_not_soft_destroyed_validator'
=>
'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'
,
'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)'
,
'featureful_models'
=>
'deleted_at DATETIME, name VARCHAR(32)'
,
'plain_models'
=>
'deleted_at DATETIME'
,
'plain_models'
=>
'deleted_at DATETIME'
,
...
@@ -964,6 +965,18 @@ class ParanoiaTest < test_framework
...
@@ -964,6 +965,18 @@ class ParanoiaTest < test_framework
related
.
valid?
related
.
valid?
end
end
def
test_assocation_not_soft_destroyed_validator
notParanoidModel
=
NotParanoidModelWithBelongsAndAssocationNotSoftDestroyedValidator
.
create
parentModel
=
ParentModel
.
create
assert
notParanoidModel
.
valid?
notParanoidModel
.
parent_model
=
parentModel
assert
notParanoidModel
.
valid?
parentModel
.
destroy
assert
!
notParanoidModel
.
valid?
assert
notParanoidModel
.
errors
.
full_messages
.
include?
"Parent model has been soft-deleted"
end
# TODO: find a fix for Rails 4.1
# TODO: find a fix for Rails 4.1
if
ActiveRecord
::
VERSION
::
STRING
!~
/\A4\.1/
if
ActiveRecord
::
VERSION
::
STRING
!~
/\A4\.1/
def
test_counter_cache_column_update_on_really_destroy
def
test_counter_cache_column_update_on_really_destroy
...
@@ -1265,6 +1278,12 @@ class NotParanoidModelWithBelong < ActiveRecord::Base
...
@@ -1265,6 +1278,12 @@ class NotParanoidModelWithBelong < ActiveRecord::Base
belongs_to
:paranoid_model_with_has_one
belongs_to
:paranoid_model_with_has_one
end
end
class
NotParanoidModelWithBelongsAndAssocationNotSoftDestroyedValidator
<
NotParanoidModelWithBelong
belongs_to
:parent_model
validates
:parent_model
,
association_not_soft_destroyed:
true
end
class
FlaggedModel
<
PlainModel
class
FlaggedModel
<
PlainModel
acts_as_paranoid
:flag_column
=>
:is_deleted
acts_as_paranoid
:flag_column
=>
:is_deleted
end
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