soft_deletion 1.8.0 → 1.10.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: 44ac482ab1a340cb83ad7befa59d3dea2f5dbb4b885b33430f8c15358e6c15ba
4
- data.tar.gz: 5da6e4c535f801c1e74f64e04bf3c49d35afe11accebd1e35539ee8b29cb61bf
3
+ metadata.gz: 558cebd07c91a09e4e4c8ed9666ec2e69f976f683638808587dd82a14a26b1a0
4
+ data.tar.gz: 70c40697c87ab55a54631b6157b60931e0955fd41a2211ab8d03a4560b790e0b
5
5
  SHA512:
6
- metadata.gz: 796131148c73d9e07411797cff502315fcff73fa5fc35f30c39c158419b35f6f744950c06053d52c4b224f695d858f381c9b09dcad6467d179496d2d0f98b253
7
- data.tar.gz: 3939b72e5a2a94c5ccae64ccb32b115f32986f0d169fbdd772c6bed3daf208d423330ae3759b7a9572f48c09ec836ac8d3933c3d4bd3f4729c7aa2ebd8ba94e2
6
+ metadata.gz: 188f18ba4882573c43409d0459bfd5f8241309d442d5cc4c928c15751952996851616b469b6ba4d40381d16d215a06d2bb80496044cf9efdcd5a37af9c1a9b3d
7
+ data.tar.gz: 2ea4e5a90ff792fad51ea8798d50ec96e1bb3099dde6cdf37a04775752e57220d43b6bc10370be1510280d738453e69de7da144d82e782fde4d2af45f1f12d20
@@ -86,14 +86,25 @@ module SoftDeletion
86
86
 
87
87
  protected
88
88
 
89
- def update_soft_delete_counter_caches(value)
90
- each_counter_cached_associations do |association|
91
- association.load_target unless association.loaded?
92
- if association.target
93
- target = association.target
94
- target.class.update_counters(target.id, association.reflection.counter_cache_column => value)
89
+ if ActiveRecord.version >= Gem::Version.new("7.2.0")
90
+ def update_soft_delete_counter_caches(value) # uncovered NOTE: covered only at Rails >= 7.2.0 tests
91
+ counter_cached_association_names.each do |association_name| # uncovered
92
+ update_soft_delete_counter_cache(association(association_name), value) # uncovered
95
93
  end
96
94
  end
95
+ else
96
+ def update_soft_delete_counter_caches(value) # uncovered NOTE: covered only at Rails < 7.2.0 tests
97
+ each_counter_cached_associations do |association| # uncovered
98
+ update_soft_delete_counter_cache(association, value) # uncovered
99
+ end
100
+ end
101
+ end
102
+
103
+ def update_soft_delete_counter_cache(association, value)
104
+ association.load_target unless association.loaded?
105
+ if (target = association.target) # uncovered TODO: add test coverage for target not existing
106
+ target.class.update_counters(target.id, association.reflection.counter_cache_column => value)
107
+ end
97
108
  end
98
109
 
99
110
  def _run_soft_delete(method, *args, **kwargs, &block)
@@ -115,7 +126,7 @@ module SoftDeletion
115
126
  end
116
127
 
117
128
  def _run_soft_undelete(&block)
118
- raise "#{self.class} is not deleted" unless deleted_at
129
+ raise "#{self.class} is not deleted" unless deleted_at # uncovered TODO: add test coverage
119
130
 
120
131
  result = false
121
132
  limit = deleted_at - 1.hour
@@ -1,3 +1,3 @@
1
1
  module SoftDeletion
2
- VERSION = '1.8.0'
2
+ VERSION = '1.10.0'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: soft_deletion
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.8.0
4
+ version: 1.10.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael Grosser
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-01-30 00:00:00.000000000 Z
11
+ date: 2024-08-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord
@@ -19,7 +19,7 @@ dependencies:
19
19
  version: 5.0.0
20
20
  - - "<"
21
21
  - !ruby/object:Gem::Version
22
- version: '7.1'
22
+ version: '7.3'
23
23
  type: :runtime
24
24
  prerelease: false
25
25
  version_requirements: !ruby/object:Gem::Requirement
@@ -29,7 +29,7 @@ dependencies:
29
29
  version: 5.0.0
30
30
  - - "<"
31
31
  - !ruby/object:Gem::Version
32
- version: '7.1'
32
+ version: '7.3'
33
33
  - !ruby/object:Gem::Dependency
34
34
  name: rake
35
35
  requirement: !ruby/object:Gem::Requirement
@@ -159,7 +159,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
159
159
  - !ruby/object:Gem::Version
160
160
  version: '0'
161
161
  requirements: []
162
- rubygems_version: 3.3.3
162
+ rubygems_version: 3.4.10
163
163
  signing_key:
164
164
  specification_version: 4
165
165
  summary: Explicit soft deletion for ActiveRecord via deleted_at and default scope.