acts_as_paranoid 0.6.1 → 0.7.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +113 -8
- data/CONTRIBUTING.md +59 -0
- data/README.md +151 -57
- data/lib/acts_as_paranoid.rb +37 -30
- data/lib/acts_as_paranoid/associations.rb +21 -17
- data/lib/acts_as_paranoid/core.rb +112 -75
- data/lib/acts_as_paranoid/relation.rb +2 -0
- data/lib/acts_as_paranoid/validations.rb +8 -74
- data/lib/acts_as_paranoid/version.rb +3 -1
- data/test/test_associations.rb +119 -43
- data/test/test_core.rb +253 -57
- data/test/test_default_scopes.rb +7 -5
- data/test/test_helper.rb +134 -64
- data/test/test_inheritance.rb +3 -1
- data/test/test_relations.rb +18 -10
- data/test/test_validations.rb +9 -7
- metadata +72 -32
- 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.2
|
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-04-16 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: activerecord
|
@@ -18,7 +18,7 @@ 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
24
|
version: '7.0'
|
@@ -28,7 +28,7 @@ dependencies:
|
|
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
34
|
version: '7.0'
|
@@ -38,7 +38,7 @@ dependencies:
|
|
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
44
|
version: '7.0'
|
@@ -48,7 +48,7 @@ dependencies:
|
|
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
54
|
version: '7.0'
|
@@ -73,7 +73,35 @@ dependencies:
|
|
73
73
|
- !ruby/object:Gem::Version
|
74
74
|
version: '3.0'
|
75
75
|
- !ruby/object:Gem::Dependency
|
76
|
-
name:
|
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
|
77
105
|
requirement: !ruby/object:Gem::Requirement
|
78
106
|
requirements:
|
79
107
|
- - ">="
|
@@ -87,7 +115,7 @@ dependencies:
|
|
87
115
|
- !ruby/object:Gem::Version
|
88
116
|
version: '0'
|
89
117
|
- !ruby/object:Gem::Dependency
|
90
|
-
name:
|
118
|
+
name: rake
|
91
119
|
requirement: !ruby/object:Gem::Requirement
|
92
120
|
requirements:
|
93
121
|
- - ">="
|
@@ -101,39 +129,53 @@ dependencies:
|
|
101
129
|
- !ruby/object:Gem::Version
|
102
130
|
version: '0'
|
103
131
|
- !ruby/object:Gem::Dependency
|
104
|
-
name:
|
132
|
+
name: rdoc
|
105
133
|
requirement: !ruby/object:Gem::Requirement
|
106
134
|
requirements:
|
107
135
|
- - ">="
|
108
136
|
- !ruby/object:Gem::Version
|
109
|
-
version: '
|
110
|
-
- - "<="
|
111
|
-
- !ruby/object:Gem::Version
|
112
|
-
version: '6.0'
|
137
|
+
version: '0'
|
113
138
|
type: :development
|
114
139
|
prerelease: false
|
115
140
|
version_requirements: !ruby/object:Gem::Requirement
|
116
141
|
requirements:
|
117
142
|
- - ">="
|
118
143
|
- !ruby/object:Gem::Version
|
119
|
-
version: '
|
120
|
-
|
144
|
+
version: '0'
|
145
|
+
- !ruby/object:Gem::Dependency
|
146
|
+
name: rubocop
|
147
|
+
requirement: !ruby/object:Gem::Requirement
|
148
|
+
requirements:
|
149
|
+
- - "~>"
|
150
|
+
- !ruby/object:Gem::Version
|
151
|
+
version: 1.12.0
|
152
|
+
type: :development
|
153
|
+
prerelease: false
|
154
|
+
version_requirements: !ruby/object:Gem::Requirement
|
155
|
+
requirements:
|
156
|
+
- - "~>"
|
121
157
|
- !ruby/object:Gem::Version
|
122
|
-
version:
|
158
|
+
version: 1.12.0
|
123
159
|
- !ruby/object:Gem::Dependency
|
124
|
-
name:
|
160
|
+
name: simplecov
|
125
161
|
requirement: !ruby/object:Gem::Requirement
|
126
162
|
requirements:
|
127
163
|
- - ">="
|
128
164
|
- !ruby/object:Gem::Version
|
129
|
-
version:
|
165
|
+
version: 0.18.1
|
166
|
+
- - "<"
|
167
|
+
- !ruby/object:Gem::Version
|
168
|
+
version: 0.22.0
|
130
169
|
type: :development
|
131
170
|
prerelease: false
|
132
171
|
version_requirements: !ruby/object:Gem::Requirement
|
133
172
|
requirements:
|
134
173
|
- - ">="
|
135
174
|
- !ruby/object:Gem::Version
|
136
|
-
version:
|
175
|
+
version: 0.18.1
|
176
|
+
- - "<"
|
177
|
+
- !ruby/object:Gem::Version
|
178
|
+
version: 0.22.0
|
137
179
|
description: Check the home page for more in-depth information.
|
138
180
|
email:
|
139
181
|
- e@zzak.io
|
@@ -142,12 +184,12 @@ extensions: []
|
|
142
184
|
extra_rdoc_files: []
|
143
185
|
files:
|
144
186
|
- CHANGELOG.md
|
187
|
+
- CONTRIBUTING.md
|
145
188
|
- LICENSE
|
146
189
|
- README.md
|
147
190
|
- lib/acts_as_paranoid.rb
|
148
191
|
- lib/acts_as_paranoid/associations.rb
|
149
192
|
- lib/acts_as_paranoid/core.rb
|
150
|
-
- lib/acts_as_paranoid/preloader_association.rb
|
151
193
|
- lib/acts_as_paranoid/relation.rb
|
152
194
|
- lib/acts_as_paranoid/validations.rb
|
153
195
|
- lib/acts_as_paranoid/version.rb
|
@@ -156,14 +198,13 @@ files:
|
|
156
198
|
- test/test_default_scopes.rb
|
157
199
|
- test/test_helper.rb
|
158
200
|
- test/test_inheritance.rb
|
159
|
-
- test/test_preloader_association.rb
|
160
201
|
- test/test_relations.rb
|
161
202
|
- test/test_validations.rb
|
162
203
|
homepage: https://github.com/ActsAsParanoid/acts_as_paranoid
|
163
204
|
licenses:
|
164
205
|
- MIT
|
165
206
|
metadata: {}
|
166
|
-
post_install_message:
|
207
|
+
post_install_message:
|
167
208
|
rdoc_options: []
|
168
209
|
require_paths:
|
169
210
|
- lib
|
@@ -171,24 +212,23 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
171
212
|
requirements:
|
172
213
|
- - ">="
|
173
214
|
- !ruby/object:Gem::Version
|
174
|
-
version:
|
215
|
+
version: 2.4.0
|
175
216
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
176
217
|
requirements:
|
177
218
|
- - ">="
|
178
219
|
- !ruby/object:Gem::Version
|
179
220
|
version: '0'
|
180
221
|
requirements: []
|
181
|
-
rubygems_version: 3.
|
182
|
-
signing_key:
|
222
|
+
rubygems_version: 3.2.3
|
223
|
+
signing_key:
|
183
224
|
specification_version: 4
|
184
225
|
summary: Active Record plugin which allows you to hide and restore records without
|
185
226
|
actually deleting them.
|
186
227
|
test_files:
|
187
|
-
- test/test_validations.rb
|
188
|
-
- test/test_relations.rb
|
189
|
-
- test/test_inheritance.rb
|
190
|
-
- test/test_default_scopes.rb
|
191
228
|
- test/test_associations.rb
|
192
|
-
- test/test_helper.rb
|
193
229
|
- test/test_core.rb
|
194
|
-
- test/
|
230
|
+
- test/test_default_scopes.rb
|
231
|
+
- test/test_helper.rb
|
232
|
+
- test/test_inheritance.rb
|
233
|
+
- test/test_relations.rb
|
234
|
+
- 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
|