acts_as_paranoid 0.7.0 → 0.7.1

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: a57d617e3e2f52608fefad1c84bba5d6825d1b9ea96e681ade8739461ef35796
4
- data.tar.gz: 549ef0573150ba7f30740a6145cb6b52ef2916b3584199fc0bab8eba17271eb0
3
+ metadata.gz: '096b348280798fe5ac4770a6c57bdb0731d2c5df9e7d361551cf065fe71f0b56'
4
+ data.tar.gz: 3d923644ebb1ccb3e06d9c04d8a0797f1677fcec880a188dd04ec8b19c9a957a
5
5
  SHA512:
6
- metadata.gz: 13ac9918fc0dc45e93d02ad799f20fe9c13afd4eba4a0b81c52201bc495a690dc80b1ab9ba9e700b7d072a61c5973dcf8d134a1049c581d61c1c0120f4444d59
7
- data.tar.gz: 6bba5d24a72d45b5de90670e1c577d6172160d1ee5d3850a3d9dd3845eb2fd73060a6d441d738b99dc9aea516189a6807c0406f377997dddf8ac443f88db6fbd
6
+ metadata.gz: e677d8e734d9c6d72fd68feaad170f928fb159ea6a90e400632ce8365f8120a991eae46508bb04d641117fa2e24d3e38e9df6699c1d70b2cd994a4cf85c49379
7
+ data.tar.gz: b58a42cbf60696baffac255deb673476e5e339dbbe4bd1681959442ca2fc33a51f6d2e146755fc8f79539976d47c6244927969c82a86fdb70a553de44281e512
data/CHANGELOG.md CHANGED
@@ -2,6 +2,13 @@
2
2
 
3
3
  Notable changes to this project will be documented in this file.
4
4
 
5
+ ## 0.7.1
6
+
7
+ * Support Rails 6.1 ([#191], by [Matijs van Zuijlen][mvz])
8
+ * Support `belongs_to` with both `:touch` and `:counter_cache` options ([#208],
9
+ by [Matijs van Zuijlen][mvz] with [Paul Druziak][pauldruziak])
10
+ * Support Ruby 3.0 ([#209], by [Matijs van Zuijlen][mvz])
11
+
5
12
  ## 0.7.0
6
13
 
7
14
  ### Breaking changes
@@ -78,6 +85,7 @@ Notable changes to this project will be documented in this file.
78
85
  [mvz]: https://github.com/mvz
79
86
  [nedcampion]: https://github.com/nedcampion
80
87
  [ri4a]: https://github.com/ri4a
88
+ [pauldruziak]: https://github.com/pauldruziak
81
89
  [shadydealer]: https://github.com/shadydealer
82
90
  [thebravoman]: https://github.com/thebravoman
83
91
  [valeriecodes]: https://github.com/valeriecodes
@@ -85,6 +93,9 @@ Notable changes to this project will be documented in this file.
85
93
 
86
94
  <!-- issues & pull requests -->
87
95
 
96
+ [#209]: https://github.com/ActsAsParanoid/acts_as_paranoid/pull/209
97
+ [#208]: https://github.com/ActsAsParanoid/acts_as_paranoid/pull/208
98
+ [#191]: https://github.com/ActsAsParanoid/acts_as_paranoid/pull/191
88
99
  [#175]: https://github.com/ActsAsParanoid/acts_as_paranoid/pull/175
89
100
  [#173]: https://github.com/ActsAsParanoid/acts_as_paranoid/pull/173
90
101
  [#171]: https://github.com/ActsAsParanoid/acts_as_paranoid/pull/171
data/README.md CHANGED
@@ -255,9 +255,9 @@ Paranoiac.create(name: 'foo').destroy
255
255
  Paranoiac.with_deleted.first.deleted? #=> true
256
256
  ```
257
257
 
258
- After the first call to .destroy the object is deleted?
258
+ After the first call to `.destroy` the object is `deleted?`.
259
259
 
260
- You can check if the object is fully destroyed with destroyed_fully? or deleted_fully?.
260
+ You can check if the object is fully destroyed with `destroyed_fully?` or `deleted_fully?`.
261
261
 
262
262
  ```ruby
263
263
  Paranoiac.create(name: 'foo').destroy
@@ -138,7 +138,7 @@ module ActsAsParanoid
138
138
  # Handle composite keys, otherwise we would just use
139
139
  # `self.class.primary_key.to_sym => self.id`.
140
140
  self.class
141
- .delete_all!(Hash[[Array(self.class.primary_key), Array(id)].transpose])
141
+ .delete_all!([Array(self.class.primary_key), Array(id)].transpose.to_h)
142
142
  decrement_counters_on_associations
143
143
  end
144
144
 
@@ -157,7 +157,7 @@ module ActsAsParanoid
157
157
  # Handle composite keys, otherwise we would just use
158
158
  # `self.class.primary_key.to_sym => self.id`.
159
159
  self.class
160
- .delete_all(Hash[[Array(self.class.primary_key), Array(id)].transpose])
160
+ .delete_all([Array(self.class.primary_key), Array(id)].transpose.to_h)
161
161
  decrement_counters_on_associations
162
162
  end
163
163
 
@@ -272,15 +272,17 @@ module ActsAsParanoid
272
272
  end
273
273
 
274
274
  def update_counters_on_associations(method_sym)
275
- return unless [:decrement_counter, :increment_counter].include? method_sym
276
-
277
275
  each_counter_cached_association_reflection do |assoc_reflection|
276
+ reflection_options = assoc_reflection.options
277
+ next unless reflection_options[:counter_cache]
278
+
278
279
  associated_object = send(assoc_reflection.name)
279
280
  next unless associated_object
280
281
 
281
282
  counter_cache_column = assoc_reflection.counter_cache_column
282
283
  associated_object.class.send(method_sym, counter_cache_column,
283
284
  associated_object.id)
285
+ associated_object.touch if reflection_options[:touch]
284
286
  end
285
287
  end
286
288
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ActsAsParanoid
4
- VERSION = "0.7.0"
4
+ VERSION = "0.7.1"
5
5
  end
data/test/test_core.rb CHANGED
@@ -539,16 +539,18 @@ class ParanoidTest < ParanoidBaseTest
539
539
  assert_equal 1, ParanoidNoDoubleTapDestroysFully.with_deleted.where(id: ps).count
540
540
  end
541
541
 
542
- def test_decrement_counters
542
+ def test_decrement_counters_without_touch
543
543
  paranoid_boolean = ParanoidBoolean.create!
544
544
  paranoid_with_counter_cache = ParanoidWithCounterCache
545
545
  .create!(paranoid_boolean: paranoid_boolean)
546
546
 
547
547
  assert_equal 1, paranoid_boolean.paranoid_with_counter_caches_count
548
+ updated_at = paranoid_boolean.reload.updated_at
548
549
 
549
550
  paranoid_with_counter_cache.destroy
550
551
 
551
552
  assert_equal 0, paranoid_boolean.reload.paranoid_with_counter_caches_count
553
+ assert_equal updated_at, paranoid_boolean.reload.updated_at
552
554
  end
553
555
 
554
556
  def test_decrement_custom_counters
@@ -563,6 +565,32 @@ class ParanoidTest < ParanoidBaseTest
563
565
  assert_equal 0, paranoid_boolean.reload.custom_counter_cache
564
566
  end
565
567
 
568
+ def test_decrement_counters_with_touch
569
+ paranoid_boolean = ParanoidBoolean.create!
570
+ paranoid_with_counter_cache = ParanoidWithTouchAndCounterCache
571
+ .create!(paranoid_boolean: paranoid_boolean)
572
+
573
+ assert_equal 1, paranoid_boolean.paranoid_with_touch_and_counter_caches_count
574
+ updated_at = paranoid_boolean.reload.updated_at
575
+
576
+ paranoid_with_counter_cache.destroy
577
+
578
+ assert_equal 0, paranoid_boolean.reload.paranoid_with_touch_and_counter_caches_count
579
+ assert_not_equal updated_at, paranoid_boolean.reload.updated_at
580
+ end
581
+
582
+ def test_touch_belongs_to
583
+ paranoid_boolean = ParanoidBoolean.create!
584
+ paranoid_with_counter_cache = ParanoidWithTouch
585
+ .create!(paranoid_boolean: paranoid_boolean)
586
+
587
+ updated_at = paranoid_boolean.reload.updated_at
588
+
589
+ paranoid_with_counter_cache.destroy
590
+
591
+ assert_not_equal updated_at, paranoid_boolean.reload.updated_at
592
+ end
593
+
566
594
  def test_destroy_with_optional_belongs_to_and_counter_cache
567
595
  ps = ParanoidWithCounterCacheOnOptionalBelognsTo.create!
568
596
  ps.destroy
data/test/test_helper.rb CHANGED
@@ -9,6 +9,14 @@ rescue Bundler::BundlerError => e
9
9
  exit e.status_code
10
10
  end
11
11
 
12
+ if RUBY_ENGINE == "jruby"
13
+ # Workaround for issue in I18n/JRuby combo.
14
+ # See https://github.com/jruby/jruby/issues/6547 and
15
+ # https://github.com/ruby-i18n/i18n/issues/555
16
+ require "i18n/backend"
17
+ require "i18n/backend/simple"
18
+ end
19
+
12
20
  require "simplecov"
13
21
  SimpleCov.start do
14
22
  enable_coverage :branch
@@ -16,6 +24,7 @@ end
16
24
 
17
25
  require "acts_as_paranoid"
18
26
  require "minitest/autorun"
27
+ require "minitest/focus"
19
28
 
20
29
  # Silence deprecation halfway through the test
21
30
  I18n.enforce_available_locales = true
@@ -41,6 +50,7 @@ def setup_db
41
50
  t.boolean :is_deleted
42
51
  t.integer :paranoid_time_id
43
52
  t.integer :paranoid_with_counter_caches_count
53
+ t.integer :paranoid_with_touch_and_counter_caches_count
44
54
  t.integer :custom_counter_cache
45
55
  timestamps t
46
56
  end
@@ -271,6 +281,8 @@ class ParanoidBoolean < ActiveRecord::Base
271
281
  has_one :paranoid_has_one_dependant, dependent: :destroy
272
282
  has_many :paranoid_with_counter_cache, dependent: :destroy
273
283
  has_many :paranoid_with_custom_counter_cache, dependent: :destroy
284
+ has_many :paranoid_with_touch_and_counter_cache, dependent: :destroy
285
+ has_many :paranoid_with_touch, dependent: :destroy
274
286
  end
275
287
 
276
288
  class ParanoidString < ActiveRecord::Base
@@ -322,6 +334,18 @@ class ParanoidWithCounterCacheOnOptionalBelognsTo < ActiveRecord::Base
322
334
  end
323
335
  end
324
336
 
337
+ class ParanoidWithTouch < ActiveRecord::Base
338
+ self.table_name = "paranoid_with_counter_caches"
339
+ acts_as_paranoid
340
+ belongs_to :paranoid_boolean, touch: true
341
+ end
342
+
343
+ class ParanoidWithTouchAndCounterCache < ActiveRecord::Base
344
+ self.table_name = "paranoid_with_counter_caches"
345
+ acts_as_paranoid
346
+ belongs_to :paranoid_boolean, touch: true, counter_cache: true
347
+ end
348
+
325
349
  class ParanoidHasManyDependant < ActiveRecord::Base
326
350
  acts_as_paranoid
327
351
  belongs_to :paranoid_time
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.7.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: 2020-08-29 00:00:00.000000000 Z
13
+ date: 2021-03-14 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: activerecord
@@ -76,22 +76,30 @@ dependencies:
76
76
  name: minitest
77
77
  requirement: !ruby/object:Gem::Requirement
78
78
  requirements:
79
- - - ">="
80
- - !ruby/object:Gem::Version
81
- version: '4.0'
82
- - - "<="
79
+ - - "~>"
83
80
  - !ruby/object:Gem::Version
84
- version: '6.0'
81
+ version: '5.14'
85
82
  type: :development
86
83
  prerelease: false
87
84
  version_requirements: !ruby/object:Gem::Requirement
88
85
  requirements:
89
- - - ">="
86
+ - - "~>"
90
87
  - !ruby/object:Gem::Version
91
- version: '4.0'
92
- - - "<="
88
+ version: '5.14'
89
+ - !ruby/object:Gem::Dependency
90
+ name: minitest-focus
91
+ requirement: !ruby/object:Gem::Requirement
92
+ requirements:
93
+ - - "~>"
93
94
  - !ruby/object:Gem::Version
94
- version: '6.0'
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
95
103
  - !ruby/object:Gem::Dependency
96
104
  name: pry
97
105
  requirement: !ruby/object:Gem::Requirement
@@ -140,14 +148,14 @@ dependencies:
140
148
  requirements:
141
149
  - - "~>"
142
150
  - !ruby/object:Gem::Version
143
- version: 0.89.1
151
+ version: 1.11.0
144
152
  type: :development
145
153
  prerelease: false
146
154
  version_requirements: !ruby/object:Gem::Requirement
147
155
  requirements:
148
156
  - - "~>"
149
157
  - !ruby/object:Gem::Version
150
- version: 0.89.1
158
+ version: 1.11.0
151
159
  - !ruby/object:Gem::Dependency
152
160
  name: simplecov
153
161
  requirement: !ruby/object:Gem::Requirement
@@ -157,7 +165,7 @@ dependencies:
157
165
  version: 0.18.1
158
166
  - - "<"
159
167
  - !ruby/object:Gem::Version
160
- version: 0.20.0
168
+ version: 0.22.0
161
169
  type: :development
162
170
  prerelease: false
163
171
  version_requirements: !ruby/object:Gem::Requirement
@@ -167,7 +175,7 @@ dependencies:
167
175
  version: 0.18.1
168
176
  - - "<"
169
177
  - !ruby/object:Gem::Version
170
- version: 0.20.0
178
+ version: 0.22.0
171
179
  description: Check the home page for more in-depth information.
172
180
  email:
173
181
  - e@zzak.io
@@ -195,7 +203,7 @@ homepage: https://github.com/ActsAsParanoid/acts_as_paranoid
195
203
  licenses:
196
204
  - MIT
197
205
  metadata: {}
198
- post_install_message:
206
+ post_install_message:
199
207
  rdoc_options: []
200
208
  require_paths:
201
209
  - lib
@@ -210,16 +218,16 @@ required_rubygems_version: !ruby/object:Gem::Requirement
210
218
  - !ruby/object:Gem::Version
211
219
  version: '0'
212
220
  requirements: []
213
- rubygems_version: 3.1.2
214
- signing_key:
221
+ rubygems_version: 3.2.3
222
+ signing_key:
215
223
  specification_version: 4
216
224
  summary: Active Record plugin which allows you to hide and restore records without
217
225
  actually deleting them.
218
226
  test_files:
219
- - test/test_relations.rb
220
- - test/test_inheritance.rb
227
+ - test/test_associations.rb
221
228
  - test/test_core.rb
222
229
  - test/test_default_scopes.rb
223
230
  - test/test_helper.rb
231
+ - test/test_inheritance.rb
232
+ - test/test_relations.rb
224
233
  - test/test_validations.rb
225
- - test/test_associations.rb