acts_as_paranoid 0.7.3 → 0.8.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2a0dd97ab43e1d7a8a72327a1abf5df84ae9d3ff36c38caed38a808aacef6b01
4
- data.tar.gz: a628f74884aff858620127b163b1998b5d790a0cfcbff4ad56e9851f962a3caf
3
+ metadata.gz: b0a0cec714f9701fb054580a39b677e73a3cfd3fa1909afd29dfedbbfdcb82d0
4
+ data.tar.gz: bef6e1c18c141b3035d5a4b3c33cad22a398d06250f1f09730ae39662e48a0ca
5
5
  SHA512:
6
- metadata.gz: 1488e86f1437d179e8aef1bc8b2e6da851a29d44ef9a93d7d2a60685bae36da50d69ec74bb19f6c4751257ddce5af556994c1d38beaef037b5753c063fdf409a
7
- data.tar.gz: 630cec48256d5baf5e859f138fcc74b0a3718f6283ee08d47b36fa96cca9feba16bd6a2e1e4a3eeb3ecc210238d5ac8eb4ea31374ca8b0cfa07b57bdb9392368
6
+ metadata.gz: 804904753df983b7e366d4a6af8f4c80b24cda018a2cd2534721f7d943cc23556a9a1a9c77a7f37de335c60a3fde99639036315f235b303a60fdefc871e693b9
7
+ data.tar.gz: 40e9a9229af5706aa62e319e49c74b60b2d89e8880d46f6106ec51ef44e1e4811715b514b5e691500abc65805dd521c6741130f8eba0b892d2738cfe8efca23a
data/CHANGELOG.md CHANGED
@@ -2,6 +2,17 @@
2
2
 
3
3
  Notable changes to this project will be documented in this file.
4
4
 
5
+ ## 0.8.0
6
+
7
+ * Do not set `paranoid_value` when destroying fully ([#238], by [Aymeric Le Dorze][aymeric-ledorze])
8
+ * Make helper methods for dependent associations private ([#239], by [Matijs van Zuijlen][mvz])
9
+ * Raise ActiveRecord::RecordNotDestroyed if destroy returns false ([#240], by [Hao Liu][leomayleomay])
10
+ * Make unscoping by `with_deleted` less blunt ([#241], by [Matijs van Zuijlen][mvz])
11
+ * Drop support for Ruby 2.4 and 2.5 ([#243] and [#245] by [Matijs van Zuijlen][mvz])
12
+ * Remove deprecated methods ([#244] by [Matijs van Zuijlen][mvz])
13
+ * Remove test files from the gem ([#261] by [Matijs van Zuijlen][mvz])
14
+ * Add support for Rails 7 ([#262] by [Vederis Leunardus][cloudsbird])
15
+
5
16
  ## 0.7.3
6
17
 
7
18
  ## Improvements
@@ -104,10 +115,12 @@ Notable changes to this project will be documented in this file.
104
115
  [AlexWheeler]: https://github.com/AlexWheeler
105
116
  [RomainAlexandre]: https://github.com/RomainAlexandre
106
117
  [avinoth]: https://github.com/avinoth
118
+ [cloudsbird]: https://github.com/cloudsbird
107
119
  [aymeric-ledorze]: https://github.com/aymeric-ledorze
108
120
  [danielricecodes]: https://github.com/danielricecodes
109
121
  [jbryant92]: https://github.com/jbryant92
110
122
  [kevinmcalear]: https://github.com/kevinmcalear
123
+ [leomayleomay]: https://github.com/leomayleomay
111
124
  [marycodes2]: https://github.com/marycodes2
112
125
  [mvz]: https://github.com/mvz
113
126
  [nedcampion]: https://github.com/nedcampion
@@ -121,6 +134,15 @@ Notable changes to this project will be documented in this file.
121
134
 
122
135
  <!-- issues & pull requests -->
123
136
 
137
+ [#262]: https://github.com/ActsAsParanoid/acts_as_paranoid/pull/262
138
+ [#261]: https://github.com/ActsAsParanoid/acts_as_paranoid/pull/261
139
+ [#245]: https://github.com/ActsAsParanoid/acts_as_paranoid/pull/245
140
+ [#244]: https://github.com/ActsAsParanoid/acts_as_paranoid/pull/244
141
+ [#243]: https://github.com/ActsAsParanoid/acts_as_paranoid/pull/243
142
+ [#241]: https://github.com/ActsAsParanoid/acts_as_paranoid/pull/241
143
+ [#240]: https://github.com/ActsAsParanoid/acts_as_paranoid/pull/240
144
+ [#239]: https://github.com/ActsAsParanoid/acts_as_paranoid/pull/239
145
+ [#238]: https://github.com/ActsAsParanoid/acts_as_paranoid/pull/238
124
146
  [#227]: https://github.com/ActsAsParanoid/acts_as_paranoid/pull/227
125
147
  [#222]: https://github.com/ActsAsParanoid/acts_as_paranoid/pull/222
126
148
  [#220]: https://github.com/ActsAsParanoid/acts_as_paranoid/pull/220
data/CONTRIBUTING.md CHANGED
@@ -5,10 +5,10 @@ help the process of handling issues and pull requests go smoothly.
5
5
 
6
6
  ## Issues
7
7
 
8
- When creating an issue, please try to provide as much information as possible.
9
- Also, please follow the guidelines below to make it easier for us to figure out
10
- what's going on. If you miss any of these points we will probably ask you to
11
- improve the ticket.
8
+ When creating an issue, please provide as much information as possible, and
9
+ follow the guidelines below to make it easier for us to figure out what's going
10
+ on. If you miss any of these points we will probably ask you to improve the
11
+ ticket.
12
12
 
13
13
  - Include a clear title describing the problem
14
14
  - Describe what you are trying to achieve
@@ -25,17 +25,16 @@ GitHub issue for it before trying to implement it yourself. That way, we can
25
25
  discuss the feature and whether it makes sense to include in ActsAsParanoid itself
26
26
  before putting in the work to implement it.
27
27
 
28
- If you want to send pull requests or patches, try to follow the instructions
29
- below. **If you get stuck, please make a pull request anyway and we'll try to
28
+ To send pull requests or patches, please follow the instructions below.
29
+ **If you get stuck, please make a pull request anyway and we'll try to
30
30
  help out.**
31
31
 
32
32
  - Make sure `rake test` runs without reporting any failures.
33
33
  - Add tests for your feature. Otherwise, we can't see if it works or if we
34
34
  break it later.
35
- - Make sure latest master merges cleanly with your branch. Things might
36
- have moved around since you forked.
37
- - Try not to include changes that are irrelevant to your feature in the
38
- same commit.
35
+ - Create a separate branch for your feature based off of latest master.
36
+ - Do not include changes that are irrelevant to your feature in the same
37
+ commit.
39
38
  - Keep an eye on the build results in GitHub Actions. If the build fails and it
40
39
  seems due to your changes, please update your pull request with a fix.
41
40
 
data/README.md CHANGED
@@ -9,9 +9,9 @@ recoverable later.
9
9
 
10
10
  ## Support
11
11
 
12
- **This branch targets Rails 5.2+ and Ruby 2.4+ only**
12
+ **This branch targets Rails 5.2+ and Ruby 2.5+ only**
13
13
 
14
- If you're working with Rails 5.1 and earlier, or with Ruby 2.3 or earlier,
14
+ If you're working with Rails 5.1 and earlier, or with Ruby 2.4 or earlier,
15
15
  please switch to the corresponding branch or require an older version of the
16
16
  `acts_as_paranoid` gem.
17
17
 
@@ -27,7 +27,7 @@ please switch to the corresponding branch or require an older version of the
27
27
  #### Install gem:
28
28
 
29
29
  ```ruby
30
- gem 'acts_as_paranoid', '~> 0.7.0'
30
+ gem 'acts_as_paranoid'
31
31
  ```
32
32
 
33
33
  ```shell
@@ -89,12 +89,7 @@ module ActsAsParanoid
89
89
  end
90
90
 
91
91
  def recovery_value
92
- if paranoid_configuration.key? :recovery_value
93
- ActiveSupport::Deprecation.warn \
94
- "The recovery_value setting is deprecated and will be removed in" \
95
- " ActsAsParanoid 0.8.0"
96
- paranoid_configuration[:recovery_value]
97
- elsif boolean_type_not_nullable?
92
+ if boolean_type_not_nullable?
98
93
  false
99
94
  else
100
95
  nil
@@ -121,9 +116,13 @@ module ActsAsParanoid
121
116
  def without_paranoid_default_scope
122
117
  scope = all
123
118
 
119
+ # unscope avoids applying the default scope when using this scope for associations
124
120
  scope = scope.unscope(where: paranoid_column)
125
- # Fix problems with unscope group chain
126
- scope = scope.unscoped if scope.to_sql.include? paranoid_default_scope.to_sql
121
+
122
+ paranoid_where_clause =
123
+ ActiveRecord::Relation::WhereClause.new([paranoid_default_scope])
124
+
125
+ scope.where_clause = all.where_clause - paranoid_where_clause
127
126
 
128
127
  scope
129
128
  end
@@ -157,7 +156,6 @@ module ActsAsParanoid
157
156
  decrement_counters_on_associations
158
157
  end
159
158
 
160
- stale_paranoid_value
161
159
  @destroyed = true
162
160
  freeze
163
161
  end
@@ -165,6 +163,12 @@ module ActsAsParanoid
165
163
  end
166
164
 
167
165
  def destroy!
166
+ destroy || raise(
167
+ ActiveRecord::RecordNotDestroyed.new("Failed to destroy the record", self)
168
+ )
169
+ end
170
+
171
+ def destroy
168
172
  if !deleted?
169
173
  with_transaction_returning_status do
170
174
  run_callbacks :destroy do
@@ -187,8 +191,6 @@ module ActsAsParanoid
187
191
  end
188
192
  end
189
193
 
190
- alias destroy destroy!
191
-
192
194
  def recover(options = {})
193
195
  return if !deleted?
194
196
 
@@ -220,23 +222,6 @@ module ActsAsParanoid
220
222
  recover(options)
221
223
  end
222
224
 
223
- def recover_dependent_associations(deleted_value, options)
224
- self.class.dependent_associations.each do |reflection|
225
- recover_dependent_association(reflection, deleted_value, options)
226
- end
227
- end
228
-
229
- def destroy_dependent_associations!
230
- self.class.dependent_associations.each do |reflection|
231
- assoc = association(reflection.name)
232
- next unless (klass = assoc.klass).paranoid?
233
-
234
- klass
235
- .only_deleted.merge(get_association_scope(assoc))
236
- .each(&:destroy!)
237
- end
238
- end
239
-
240
225
  def deleted?
241
226
  return true if @destroyed
242
227
 
@@ -259,6 +244,23 @@ module ActsAsParanoid
259
244
 
260
245
  private
261
246
 
247
+ def recover_dependent_associations(deleted_value, options)
248
+ self.class.dependent_associations.each do |reflection|
249
+ recover_dependent_association(reflection, deleted_value, options)
250
+ end
251
+ end
252
+
253
+ def destroy_dependent_associations!
254
+ self.class.dependent_associations.each do |reflection|
255
+ assoc = association(reflection.name)
256
+ next unless (klass = assoc.klass).paranoid?
257
+
258
+ klass
259
+ .only_deleted.merge(get_association_scope(assoc))
260
+ .each(&:destroy!)
261
+ end
262
+ end
263
+
262
264
  def recover_dependent_association(reflection, deleted_value, options)
263
265
  assoc = association(reflection.name)
264
266
  return unless (klass = assoc.klass).paranoid?
@@ -29,13 +29,6 @@ module ActsAsParanoid
29
29
  end
30
30
  end
31
31
 
32
- def destroy!(id_or_array)
33
- destroy_fully! id_or_array
34
- end
35
-
36
- deprecate :destroy!,
37
- deprecator: ActiveSupport::Deprecation.new("0.8.0", "ActsAsParanoid")
38
-
39
32
  def destroy_fully!(id_or_array)
40
33
  where(primary_key => id_or_array).orig_delete_all
41
34
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ActsAsParanoid
4
- VERSION = "0.7.3"
4
+ VERSION = "0.8.0"
5
5
  end
@@ -36,8 +36,9 @@ module ActsAsParanoid
36
36
  paranoid_configuration.merge!(options) # user options
37
37
 
38
38
  unless %w[time boolean string].include? paranoid_configuration[:column_type]
39
- raise ArgumentError, "'time', 'boolean' or 'string' expected" \
40
- " for :column_type option, got #{paranoid_configuration[:column_type]}"
39
+ raise ArgumentError,
40
+ "'time', 'boolean' or 'string' expected for :column_type option," \
41
+ " got #{paranoid_configuration[:column_type]}"
41
42
  end
42
43
 
43
44
  return if paranoid?
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: acts_as_paranoid
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.3
4
+ version: 0.8.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Zachary Scott
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2021-05-02 00:00:00.000000000 Z
13
+ date: 2021-12-17 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: activerecord
@@ -21,7 +21,7 @@ dependencies:
21
21
  version: '5.2'
22
22
  - - "<"
23
23
  - !ruby/object:Gem::Version
24
- version: '7.0'
24
+ version: '7.1'
25
25
  type: :runtime
26
26
  prerelease: false
27
27
  version_requirements: !ruby/object:Gem::Requirement
@@ -31,7 +31,7 @@ dependencies:
31
31
  version: '5.2'
32
32
  - - "<"
33
33
  - !ruby/object:Gem::Version
34
- version: '7.0'
34
+ version: '7.1'
35
35
  - !ruby/object:Gem::Dependency
36
36
  name: activesupport
37
37
  requirement: !ruby/object:Gem::Requirement
@@ -41,7 +41,7 @@ dependencies:
41
41
  version: '5.2'
42
42
  - - "<"
43
43
  - !ruby/object:Gem::Version
44
- version: '7.0'
44
+ version: '7.1'
45
45
  type: :runtime
46
46
  prerelease: false
47
47
  version_requirements: !ruby/object:Gem::Requirement
@@ -51,131 +51,133 @@ dependencies:
51
51
  version: '5.2'
52
52
  - - "<"
53
53
  - !ruby/object:Gem::Version
54
- version: '7.0'
54
+ version: '7.1'
55
55
  - !ruby/object:Gem::Dependency
56
- name: bundler
56
+ name: minitest
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - ">="
60
- - !ruby/object:Gem::Version
61
- version: '1.5'
62
- - - "<"
59
+ - - "~>"
63
60
  - !ruby/object:Gem::Version
64
- version: '3.0'
61
+ version: '5.14'
65
62
  type: :development
66
63
  prerelease: false
67
64
  version_requirements: !ruby/object:Gem::Requirement
68
65
  requirements:
69
- - - ">="
70
- - !ruby/object:Gem::Version
71
- version: '1.5'
72
- - - "<"
66
+ - - "~>"
73
67
  - !ruby/object:Gem::Version
74
- version: '3.0'
68
+ version: '5.14'
75
69
  - !ruby/object:Gem::Dependency
76
- name: minitest
70
+ name: minitest-focus
77
71
  requirement: !ruby/object:Gem::Requirement
78
72
  requirements:
79
73
  - - "~>"
80
74
  - !ruby/object:Gem::Version
81
- version: '5.14'
75
+ version: 1.3.0
82
76
  type: :development
83
77
  prerelease: false
84
78
  version_requirements: !ruby/object:Gem::Requirement
85
79
  requirements:
86
80
  - - "~>"
87
81
  - !ruby/object:Gem::Version
88
- version: '5.14'
82
+ version: 1.3.0
89
83
  - !ruby/object:Gem::Dependency
90
- name: minitest-focus
84
+ name: pry
91
85
  requirement: !ruby/object:Gem::Requirement
92
86
  requirements:
93
87
  - - "~>"
94
88
  - !ruby/object:Gem::Version
95
- version: 1.2.1
89
+ version: 0.14.1
96
90
  type: :development
97
91
  prerelease: false
98
92
  version_requirements: !ruby/object:Gem::Requirement
99
93
  requirements:
100
94
  - - "~>"
101
95
  - !ruby/object:Gem::Version
102
- version: 1.2.1
96
+ version: 0.14.1
103
97
  - !ruby/object:Gem::Dependency
104
- name: pry
98
+ name: rake
105
99
  requirement: !ruby/object:Gem::Requirement
106
100
  requirements:
107
- - - ">="
101
+ - - "~>"
108
102
  - !ruby/object:Gem::Version
109
- version: '0'
103
+ version: '13.0'
110
104
  type: :development
111
105
  prerelease: false
112
106
  version_requirements: !ruby/object:Gem::Requirement
113
107
  requirements:
114
- - - ">="
108
+ - - "~>"
115
109
  - !ruby/object:Gem::Version
116
- version: '0'
110
+ version: '13.0'
117
111
  - !ruby/object:Gem::Dependency
118
- name: rake
112
+ name: rake-manifest
119
113
  requirement: !ruby/object:Gem::Requirement
120
114
  requirements:
121
- - - ">="
115
+ - - "~>"
122
116
  - !ruby/object:Gem::Version
123
- version: '0'
117
+ version: 0.2.0
124
118
  type: :development
125
119
  prerelease: false
126
120
  version_requirements: !ruby/object:Gem::Requirement
127
121
  requirements:
128
- - - ">="
122
+ - - "~>"
129
123
  - !ruby/object:Gem::Version
130
- version: '0'
124
+ version: 0.2.0
131
125
  - !ruby/object:Gem::Dependency
132
126
  name: rdoc
133
127
  requirement: !ruby/object:Gem::Requirement
134
128
  requirements:
135
- - - ">="
129
+ - - "~>"
136
130
  - !ruby/object:Gem::Version
137
- version: '0'
131
+ version: '6.3'
138
132
  type: :development
139
133
  prerelease: false
140
134
  version_requirements: !ruby/object:Gem::Requirement
141
135
  requirements:
142
- - - ">="
136
+ - - "~>"
143
137
  - !ruby/object:Gem::Version
144
- version: '0'
138
+ version: '6.3'
145
139
  - !ruby/object:Gem::Dependency
146
140
  name: rubocop
147
141
  requirement: !ruby/object:Gem::Requirement
148
142
  requirements:
149
143
  - - "~>"
150
144
  - !ruby/object:Gem::Version
151
- version: 1.12.0
145
+ version: 1.23.0
152
146
  type: :development
153
147
  prerelease: false
154
148
  version_requirements: !ruby/object:Gem::Requirement
155
149
  requirements:
156
150
  - - "~>"
157
151
  - !ruby/object:Gem::Version
158
- version: 1.12.0
152
+ version: 1.23.0
159
153
  - !ruby/object:Gem::Dependency
160
- name: simplecov
154
+ name: rubocop-minitest
161
155
  requirement: !ruby/object:Gem::Requirement
162
156
  requirements:
163
- - - ">="
164
- - !ruby/object:Gem::Version
165
- version: 0.18.1
166
- - - "<"
157
+ - - "~>"
167
158
  - !ruby/object:Gem::Version
168
- version: 0.22.0
159
+ version: 0.17.0
169
160
  type: :development
170
161
  prerelease: false
171
162
  version_requirements: !ruby/object:Gem::Requirement
172
163
  requirements:
173
- - - ">="
164
+ - - "~>"
174
165
  - !ruby/object:Gem::Version
175
- version: 0.18.1
176
- - - "<"
166
+ version: 0.17.0
167
+ - !ruby/object:Gem::Dependency
168
+ name: simplecov
169
+ requirement: !ruby/object:Gem::Requirement
170
+ requirements:
171
+ - - "~>"
172
+ - !ruby/object:Gem::Version
173
+ version: 0.21.2
174
+ type: :development
175
+ prerelease: false
176
+ version_requirements: !ruby/object:Gem::Requirement
177
+ requirements:
178
+ - - "~>"
177
179
  - !ruby/object:Gem::Version
178
- version: 0.22.0
180
+ version: 0.21.2
179
181
  description: Check the home page for more in-depth information.
180
182
  email:
181
183
  - e@zzak.io
@@ -193,20 +195,11 @@ files:
193
195
  - lib/acts_as_paranoid/relation.rb
194
196
  - lib/acts_as_paranoid/validations.rb
195
197
  - lib/acts_as_paranoid/version.rb
196
- - test/test_associations.rb
197
- - test/test_core.rb
198
- - test/test_default_scopes.rb
199
- - test/test_dependent_recovery.rb
200
- - test/test_deprecated_behavior.rb
201
- - test/test_helper.rb
202
- - test/test_inheritance.rb
203
- - test/test_relations.rb
204
- - test/test_table_namespace.rb
205
- - test/test_validations.rb
206
198
  homepage: https://github.com/ActsAsParanoid/acts_as_paranoid
207
199
  licenses:
208
200
  - MIT
209
- metadata: {}
201
+ metadata:
202
+ rubygems_mfa_required: 'true'
210
203
  post_install_message:
211
204
  rdoc_options: []
212
205
  require_paths:
@@ -215,26 +208,16 @@ required_ruby_version: !ruby/object:Gem::Requirement
215
208
  requirements:
216
209
  - - ">="
217
210
  - !ruby/object:Gem::Version
218
- version: 2.4.0
211
+ version: 2.6.0
219
212
  required_rubygems_version: !ruby/object:Gem::Requirement
220
213
  requirements:
221
214
  - - ">="
222
215
  - !ruby/object:Gem::Version
223
216
  version: '0'
224
217
  requirements: []
225
- rubygems_version: 3.2.3
218
+ rubygems_version: 3.2.33
226
219
  signing_key:
227
220
  specification_version: 4
228
221
  summary: Active Record plugin which allows you to hide and restore records without
229
222
  actually deleting them.
230
- test_files:
231
- - test/test_associations.rb
232
- - test/test_core.rb
233
- - test/test_default_scopes.rb
234
- - test/test_dependent_recovery.rb
235
- - test/test_deprecated_behavior.rb
236
- - test/test_helper.rb
237
- - test/test_inheritance.rb
238
- - test/test_relations.rb
239
- - test/test_table_namespace.rb
240
- - test/test_validations.rb
223
+ test_files: []