acts_as_paranoid 0.6.0 → 0.7.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +128 -0
- data/README.md +154 -56
- data/lib/acts_as_paranoid.rb +34 -31
- data/lib/acts_as_paranoid/associations.rb +21 -17
- data/lib/acts_as_paranoid/core.rb +139 -58
- data/lib/acts_as_paranoid/relation.rb +2 -0
- data/lib/acts_as_paranoid/validations.rb +8 -69
- data/lib/acts_as_paranoid/version.rb +3 -1
- data/test/test_associations.rb +157 -38
- data/test/test_core.rb +269 -48
- data/test/test_default_scopes.rb +7 -6
- data/test/test_helper.rb +155 -62
- data/test/test_inheritance.rb +3 -1
- data/test/test_relations.rb +18 -10
- data/test/test_validations.rb +9 -7
- metadata +92 -33
- data/lib/acts_as_paranoid/preloader_association.rb +0 -16
- data/test/test_preloader_association.rb +0 -27
data/test/test_validations.rb
CHANGED
@@ -1,8 +1,10 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "test_helper"
|
2
4
|
|
3
5
|
class ValidatesUniquenessTest < ParanoidBaseTest
|
4
6
|
def test_should_include_deleted_by_default
|
5
|
-
ParanoidTime.new(:
|
7
|
+
ParanoidTime.new(name: "paranoid").tap do |record|
|
6
8
|
assert !record.valid?
|
7
9
|
ParanoidTime.first.destroy
|
8
10
|
assert !record.valid?
|
@@ -12,7 +14,7 @@ class ValidatesUniquenessTest < ParanoidBaseTest
|
|
12
14
|
end
|
13
15
|
|
14
16
|
def test_should_validate_without_deleted
|
15
|
-
ParanoidBoolean.new(:
|
17
|
+
ParanoidBoolean.new(name: "paranoid").tap do |record|
|
16
18
|
refute record.valid?
|
17
19
|
ParanoidBoolean.first.destroy
|
18
20
|
assert record.valid?
|
@@ -22,8 +24,8 @@ class ValidatesUniquenessTest < ParanoidBaseTest
|
|
22
24
|
end
|
23
25
|
|
24
26
|
def test_models_with_scoped_validations_can_be_multiply_deleted
|
25
|
-
model_a = ParanoidWithScopedValidation.create(:
|
26
|
-
model_b = ParanoidWithScopedValidation.create(:
|
27
|
+
model_a = ParanoidWithScopedValidation.create(name: "Model A", category: "Category A")
|
28
|
+
model_b = ParanoidWithScopedValidation.create(name: "Model B", category: "Category B")
|
27
29
|
|
28
30
|
ParanoidWithScopedValidation.delete([model_a.id, model_b.id])
|
29
31
|
|
@@ -32,8 +34,8 @@ class ValidatesUniquenessTest < ParanoidBaseTest
|
|
32
34
|
end
|
33
35
|
|
34
36
|
def test_models_with_scoped_validations_can_be_multiply_destroyed
|
35
|
-
model_a = ParanoidWithScopedValidation.create(:
|
36
|
-
model_b = ParanoidWithScopedValidation.create(:
|
37
|
+
model_a = ParanoidWithScopedValidation.create(name: "Model A", category: "Category A")
|
38
|
+
model_b = ParanoidWithScopedValidation.create(name: "Model B", category: "Category B")
|
37
39
|
|
38
40
|
ParanoidWithScopedValidation.destroy([model_a.id, model_b.id])
|
39
41
|
|
metadata
CHANGED
@@ -1,16 +1,16 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: acts_as_paranoid
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.7.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Zachary Scott
|
8
8
|
- Goncalo Silva
|
9
9
|
- Rick Olson
|
10
|
-
autorequire:
|
10
|
+
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date:
|
13
|
+
date: 2021-03-14 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: activerecord
|
@@ -18,54 +18,102 @@ dependencies:
|
|
18
18
|
requirements:
|
19
19
|
- - ">="
|
20
20
|
- !ruby/object:Gem::Version
|
21
|
-
version: '
|
21
|
+
version: '5.2'
|
22
22
|
- - "<"
|
23
23
|
- !ruby/object:Gem::Version
|
24
|
-
version: '
|
24
|
+
version: '7.0'
|
25
25
|
type: :runtime
|
26
26
|
prerelease: false
|
27
27
|
version_requirements: !ruby/object:Gem::Requirement
|
28
28
|
requirements:
|
29
29
|
- - ">="
|
30
30
|
- !ruby/object:Gem::Version
|
31
|
-
version: '
|
31
|
+
version: '5.2'
|
32
32
|
- - "<"
|
33
33
|
- !ruby/object:Gem::Version
|
34
|
-
version: '
|
34
|
+
version: '7.0'
|
35
35
|
- !ruby/object:Gem::Dependency
|
36
36
|
name: activesupport
|
37
37
|
requirement: !ruby/object:Gem::Requirement
|
38
38
|
requirements:
|
39
39
|
- - ">="
|
40
40
|
- !ruby/object:Gem::Version
|
41
|
-
version: '
|
41
|
+
version: '5.2'
|
42
42
|
- - "<"
|
43
43
|
- !ruby/object:Gem::Version
|
44
|
-
version: '
|
44
|
+
version: '7.0'
|
45
45
|
type: :runtime
|
46
46
|
prerelease: false
|
47
47
|
version_requirements: !ruby/object:Gem::Requirement
|
48
48
|
requirements:
|
49
49
|
- - ">="
|
50
50
|
- !ruby/object:Gem::Version
|
51
|
-
version: '
|
51
|
+
version: '5.2'
|
52
52
|
- - "<"
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: '
|
54
|
+
version: '7.0'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: bundler
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- - "
|
59
|
+
- - ">="
|
60
60
|
- !ruby/object:Gem::Version
|
61
61
|
version: '1.5'
|
62
|
+
- - "<"
|
63
|
+
- !ruby/object:Gem::Version
|
64
|
+
version: '3.0'
|
62
65
|
type: :development
|
63
66
|
prerelease: false
|
64
67
|
version_requirements: !ruby/object:Gem::Requirement
|
65
68
|
requirements:
|
66
|
-
- - "
|
69
|
+
- - ">="
|
67
70
|
- !ruby/object:Gem::Version
|
68
71
|
version: '1.5'
|
72
|
+
- - "<"
|
73
|
+
- !ruby/object:Gem::Version
|
74
|
+
version: '3.0'
|
75
|
+
- !ruby/object:Gem::Dependency
|
76
|
+
name: minitest
|
77
|
+
requirement: !ruby/object:Gem::Requirement
|
78
|
+
requirements:
|
79
|
+
- - "~>"
|
80
|
+
- !ruby/object:Gem::Version
|
81
|
+
version: '5.14'
|
82
|
+
type: :development
|
83
|
+
prerelease: false
|
84
|
+
version_requirements: !ruby/object:Gem::Requirement
|
85
|
+
requirements:
|
86
|
+
- - "~>"
|
87
|
+
- !ruby/object:Gem::Version
|
88
|
+
version: '5.14'
|
89
|
+
- !ruby/object:Gem::Dependency
|
90
|
+
name: minitest-focus
|
91
|
+
requirement: !ruby/object:Gem::Requirement
|
92
|
+
requirements:
|
93
|
+
- - "~>"
|
94
|
+
- !ruby/object:Gem::Version
|
95
|
+
version: 1.2.1
|
96
|
+
type: :development
|
97
|
+
prerelease: false
|
98
|
+
version_requirements: !ruby/object:Gem::Requirement
|
99
|
+
requirements:
|
100
|
+
- - "~>"
|
101
|
+
- !ruby/object:Gem::Version
|
102
|
+
version: 1.2.1
|
103
|
+
- !ruby/object:Gem::Dependency
|
104
|
+
name: pry
|
105
|
+
requirement: !ruby/object:Gem::Requirement
|
106
|
+
requirements:
|
107
|
+
- - ">="
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: '0'
|
110
|
+
type: :development
|
111
|
+
prerelease: false
|
112
|
+
version_requirements: !ruby/object:Gem::Requirement
|
113
|
+
requirements:
|
114
|
+
- - ">="
|
115
|
+
- !ruby/object:Gem::Version
|
116
|
+
version: '0'
|
69
117
|
- !ruby/object:Gem::Dependency
|
70
118
|
name: rake
|
71
119
|
requirement: !ruby/object:Gem::Requirement
|
@@ -95,25 +143,39 @@ dependencies:
|
|
95
143
|
- !ruby/object:Gem::Version
|
96
144
|
version: '0'
|
97
145
|
- !ruby/object:Gem::Dependency
|
98
|
-
name:
|
146
|
+
name: rubocop
|
147
|
+
requirement: !ruby/object:Gem::Requirement
|
148
|
+
requirements:
|
149
|
+
- - "~>"
|
150
|
+
- !ruby/object:Gem::Version
|
151
|
+
version: 1.11.0
|
152
|
+
type: :development
|
153
|
+
prerelease: false
|
154
|
+
version_requirements: !ruby/object:Gem::Requirement
|
155
|
+
requirements:
|
156
|
+
- - "~>"
|
157
|
+
- !ruby/object:Gem::Version
|
158
|
+
version: 1.11.0
|
159
|
+
- !ruby/object:Gem::Dependency
|
160
|
+
name: simplecov
|
99
161
|
requirement: !ruby/object:Gem::Requirement
|
100
162
|
requirements:
|
101
163
|
- - ">="
|
102
164
|
- !ruby/object:Gem::Version
|
103
|
-
version:
|
104
|
-
- - "
|
165
|
+
version: 0.18.1
|
166
|
+
- - "<"
|
105
167
|
- !ruby/object:Gem::Version
|
106
|
-
version:
|
168
|
+
version: 0.22.0
|
107
169
|
type: :development
|
108
170
|
prerelease: false
|
109
171
|
version_requirements: !ruby/object:Gem::Requirement
|
110
172
|
requirements:
|
111
173
|
- - ">="
|
112
174
|
- !ruby/object:Gem::Version
|
113
|
-
version:
|
114
|
-
- - "
|
175
|
+
version: 0.18.1
|
176
|
+
- - "<"
|
115
177
|
- !ruby/object:Gem::Version
|
116
|
-
version:
|
178
|
+
version: 0.22.0
|
117
179
|
description: Check the home page for more in-depth information.
|
118
180
|
email:
|
119
181
|
- e@zzak.io
|
@@ -121,12 +183,12 @@ executables: []
|
|
121
183
|
extensions: []
|
122
184
|
extra_rdoc_files: []
|
123
185
|
files:
|
186
|
+
- CHANGELOG.md
|
124
187
|
- LICENSE
|
125
188
|
- README.md
|
126
189
|
- lib/acts_as_paranoid.rb
|
127
190
|
- lib/acts_as_paranoid/associations.rb
|
128
191
|
- lib/acts_as_paranoid/core.rb
|
129
|
-
- lib/acts_as_paranoid/preloader_association.rb
|
130
192
|
- lib/acts_as_paranoid/relation.rb
|
131
193
|
- lib/acts_as_paranoid/validations.rb
|
132
194
|
- lib/acts_as_paranoid/version.rb
|
@@ -135,14 +197,13 @@ files:
|
|
135
197
|
- test/test_default_scopes.rb
|
136
198
|
- test/test_helper.rb
|
137
199
|
- test/test_inheritance.rb
|
138
|
-
- test/test_preloader_association.rb
|
139
200
|
- test/test_relations.rb
|
140
201
|
- test/test_validations.rb
|
141
202
|
homepage: https://github.com/ActsAsParanoid/acts_as_paranoid
|
142
203
|
licenses:
|
143
204
|
- MIT
|
144
205
|
metadata: {}
|
145
|
-
post_install_message:
|
206
|
+
post_install_message:
|
146
207
|
rdoc_options: []
|
147
208
|
require_paths:
|
148
209
|
- lib
|
@@ -150,25 +211,23 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
150
211
|
requirements:
|
151
212
|
- - ">="
|
152
213
|
- !ruby/object:Gem::Version
|
153
|
-
version:
|
214
|
+
version: 2.4.0
|
154
215
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
155
216
|
requirements:
|
156
217
|
- - ">="
|
157
218
|
- !ruby/object:Gem::Version
|
158
219
|
version: '0'
|
159
220
|
requirements: []
|
160
|
-
|
161
|
-
|
162
|
-
signing_key:
|
221
|
+
rubygems_version: 3.2.3
|
222
|
+
signing_key:
|
163
223
|
specification_version: 4
|
164
224
|
summary: Active Record plugin which allows you to hide and restore records without
|
165
225
|
actually deleting them.
|
166
226
|
test_files:
|
167
|
-
- test/test_validations.rb
|
168
|
-
- test/test_relations.rb
|
169
|
-
- test/test_inheritance.rb
|
170
|
-
- test/test_default_scopes.rb
|
171
227
|
- test/test_associations.rb
|
172
|
-
- test/test_helper.rb
|
173
228
|
- test/test_core.rb
|
174
|
-
- test/
|
229
|
+
- test/test_default_scopes.rb
|
230
|
+
- test/test_helper.rb
|
231
|
+
- test/test_inheritance.rb
|
232
|
+
- test/test_relations.rb
|
233
|
+
- test/test_validations.rb
|
@@ -1,16 +0,0 @@
|
|
1
|
-
module ActsAsParanoid
|
2
|
-
module PreloaderAssociation
|
3
|
-
def self.included(base)
|
4
|
-
base.class_eval do
|
5
|
-
def build_scope_with_deleted
|
6
|
-
scope = build_scope_without_deleted
|
7
|
-
scope = scope.with_deleted if reflection.options[:with_deleted] && klass.respond_to?(:with_deleted)
|
8
|
-
scope
|
9
|
-
end
|
10
|
-
|
11
|
-
alias_method :build_scope_without_deleted, :build_scope
|
12
|
-
alias_method :build_scope, :build_scope_with_deleted
|
13
|
-
end
|
14
|
-
end
|
15
|
-
end
|
16
|
-
end
|
@@ -1,27 +0,0 @@
|
|
1
|
-
require 'test_helper'
|
2
|
-
|
3
|
-
class PreloaderAssociationTest < ParanoidBaseTest
|
4
|
-
def test_includes_with_deleted
|
5
|
-
paranoid_time = ParanoidTime.first
|
6
|
-
paranoid_has_many_dependant = paranoid_time.paranoid_has_many_dependants.create(:name => 'dependant!')
|
7
|
-
|
8
|
-
paranoid_time.destroy
|
9
|
-
|
10
|
-
ParanoidHasManyDependant.with_deleted.includes(:paranoid_time_with_deleted).each do |hasmany|
|
11
|
-
assert_not_nil hasmany.paranoid_time_with_deleted
|
12
|
-
end
|
13
|
-
end
|
14
|
-
|
15
|
-
def test_includes_with_deleted_with_polymorphic_parent
|
16
|
-
not_paranoid_parent = NotParanoidHasManyAsParent.create(name: 'not paranoid parent')
|
17
|
-
paranoid_parent = ParanoidHasManyAsParent.create(name: 'paranoid parent')
|
18
|
-
ParanoidBelongsToPolymorphic.create(:name => 'belongs_to', :parent => not_paranoid_parent)
|
19
|
-
ParanoidBelongsToPolymorphic.create(:name => 'belongs_to', :parent => paranoid_parent)
|
20
|
-
|
21
|
-
paranoid_parent.destroy
|
22
|
-
|
23
|
-
ParanoidBelongsToPolymorphic.with_deleted.includes(:parent).each do |hasmany|
|
24
|
-
assert_not_nil hasmany.parent
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|