paranoia 2.4.2 → 2.4.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +16 -10
- data/lib/paranoia.rb +6 -1
- data/lib/paranoia/version.rb +1 -1
- data/paranoia.gemspec +1 -1
- data/test/paranoia_test.rb +15 -0
- metadata +8 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d0174a966648c3afbf8ce8d09ef65361c48540838e705bb3327477f36ee27eff
|
4
|
+
data.tar.gz: 70a9eb72fa2cfda78c4adf5aa9918404ad5860d725ac657959f0b105fd300276
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2a960433d0574c324778ae6774cc90501ee3a108c91e8aca45f91eeb59b1a80406b861b94e68b7fe391dc50c32fb7ebc034aa43296ec6ffd3bb78e863051a067
|
7
|
+
data.tar.gz: 765b1c436d256277a0ac54947584b90c69ffec5bad08011696e4a62267d1bf1e3b782957d904425933083b12e1fa3ce2668872acc83e04877304243ea96f9a61
|
data/.travis.yml
CHANGED
@@ -1,14 +1,15 @@
|
|
1
1
|
sudo: false
|
2
2
|
language: ruby
|
3
|
-
before_install:
|
3
|
+
before_install:
|
4
|
+
- gem query -I -n "^bundler$" -v ">=2" || gem uninstall -x bundler -v ">=2" || rvm @global do gem uninstall -x bundler -v ">=2"
|
5
|
+
- gem query -i -n "^bundler$" -v "<2" || gem install bundler -v "<2"
|
4
6
|
cache: bundler
|
5
7
|
rvm:
|
6
|
-
- 2.2
|
7
8
|
- 2.3.8
|
8
9
|
- 2.4.5
|
9
10
|
- 2.5.3
|
10
11
|
- 2.6.3
|
11
|
-
- jruby-9.
|
12
|
+
- jruby-9.2.8.0
|
12
13
|
|
13
14
|
env:
|
14
15
|
matrix:
|
@@ -16,24 +17,29 @@ env:
|
|
16
17
|
- RAILS='~> 5.0.0' SQLITE_VERSION='~> 1.3.6'
|
17
18
|
- RAILS='~> 5.1.0'
|
18
19
|
- RAILS='~> 5.2.0'
|
20
|
+
- RAILS='~> 6.1.0'
|
19
21
|
- RAILS='master'
|
20
22
|
|
21
23
|
matrix:
|
22
24
|
allow_failures:
|
23
25
|
- env: RAILS='~> 4.2.0' SQLITE_VERSION='~> 1.3.6'
|
24
|
-
rvm: jruby-9.
|
26
|
+
rvm: jruby-9.2.8.0
|
25
27
|
- env: RAILS='~> 5.0.0' SQLITE_VERSION='~> 1.3.6'
|
26
|
-
rvm: jruby-9.
|
28
|
+
rvm: jruby-9.2.8.0
|
27
29
|
- env: RAILS='~> 5.1.0'
|
28
|
-
rvm: jruby-9.
|
30
|
+
rvm: jruby-9.2.8.0
|
29
31
|
- env: RAILS='~> 5.2.0'
|
30
|
-
rvm: jruby-9.
|
32
|
+
rvm: jruby-9.2.8.0
|
31
33
|
- env: RAILS='master'
|
32
|
-
rvm: jruby-9.
|
34
|
+
rvm: jruby-9.2.8.0
|
35
|
+
- env: RAILS='~> 6.1.0'
|
36
|
+
rvm: jruby-9.2.8.0
|
33
37
|
exclude:
|
34
|
-
- rvm: 2.2
|
35
|
-
env: RAILS='master'
|
36
38
|
- rvm: 2.3.8
|
37
39
|
env: RAILS='master'
|
38
40
|
- rvm: 2.4.5
|
39
41
|
env: RAILS='master'
|
42
|
+
- rvm: 2.3.8
|
43
|
+
env: RAILS='~> 6.1.0'
|
44
|
+
- rvm: 2.4.5
|
45
|
+
env: RAILS='~> 6.1.0'
|
data/lib/paranoia.rb
CHANGED
@@ -69,6 +69,7 @@ module Paranoia
|
|
69
69
|
next unless send(association.reflection.name)
|
70
70
|
association.decrement_counters
|
71
71
|
end
|
72
|
+
@_trigger_destroy_callback = true
|
72
73
|
@_disable_counter_cache = false
|
73
74
|
result
|
74
75
|
end
|
@@ -81,6 +82,10 @@ module Paranoia
|
|
81
82
|
raise(ActiveRecord::RecordNotDestroyed.new("Failed to destroy the record", self))
|
82
83
|
end
|
83
84
|
|
85
|
+
def trigger_transactional_callbacks?
|
86
|
+
super || @_trigger_destroy_callback && paranoia_destroyed?
|
87
|
+
end
|
88
|
+
|
84
89
|
def paranoia_delete
|
85
90
|
raise ActiveRecord::ReadOnlyRecord, "#{self.class} is marked as readonly" if readonly?
|
86
91
|
if persisted?
|
@@ -311,7 +316,7 @@ module ActiveRecord
|
|
311
316
|
def validate_each(record, attribute, value)
|
312
317
|
# if association is soft destroyed, add an error
|
313
318
|
if value.present? && value.paranoia_destroyed?
|
314
|
-
record.errors
|
319
|
+
record.errors.add(attribute, 'has been soft-deleted')
|
315
320
|
end
|
316
321
|
end
|
317
322
|
end
|
data/lib/paranoia/version.rb
CHANGED
data/paranoia.gemspec
CHANGED
@@ -24,7 +24,7 @@ Gem::Specification.new do |s|
|
|
24
24
|
|
25
25
|
s.required_ruby_version = '>= 2.0'
|
26
26
|
|
27
|
-
s.add_dependency 'activerecord', '>= 4.0', '< 6.
|
27
|
+
s.add_dependency 'activerecord', '>= 4.0', '< 6.2'
|
28
28
|
|
29
29
|
s.add_development_dependency "bundler", ">= 1.0.0"
|
30
30
|
s.add_development_dependency "rake"
|
data/test/paranoia_test.rb
CHANGED
@@ -131,6 +131,21 @@ class ParanoiaTest < test_framework
|
|
131
131
|
assert model.instance_variable_get(:@after_commit_callback_called)
|
132
132
|
end
|
133
133
|
|
134
|
+
def test_destroy_behavior_for_freshly_loaded_plain_models_callbacks
|
135
|
+
model = CallbackModel.new
|
136
|
+
model.save
|
137
|
+
|
138
|
+
model = CallbackModel.find(model.id)
|
139
|
+
model.destroy
|
140
|
+
|
141
|
+
assert_nil model.instance_variable_get(:@update_callback_called)
|
142
|
+
assert_nil model.instance_variable_get(:@save_callback_called)
|
143
|
+
assert_nil model.instance_variable_get(:@validate_called)
|
144
|
+
|
145
|
+
assert model.instance_variable_get(:@destroy_callback_called)
|
146
|
+
assert model.instance_variable_get(:@after_destroy_callback_called)
|
147
|
+
assert model.instance_variable_get(:@after_commit_callback_called)
|
148
|
+
end
|
134
149
|
|
135
150
|
def test_delete_behavior_for_plain_models_callbacks
|
136
151
|
model = CallbackModel.new
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: paranoia
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.4.
|
4
|
+
version: 2.4.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- radarlistener@gmail.com
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-12-16 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: '4.0'
|
20
20
|
- - "<"
|
21
21
|
- !ruby/object:Gem::Version
|
22
|
-
version: '6.
|
22
|
+
version: '6.2'
|
23
23
|
type: :runtime
|
24
24
|
prerelease: false
|
25
25
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -29,7 +29,7 @@ dependencies:
|
|
29
29
|
version: '4.0'
|
30
30
|
- - "<"
|
31
31
|
- !ruby/object:Gem::Version
|
32
|
-
version: '6.
|
32
|
+
version: '6.2'
|
33
33
|
- !ruby/object:Gem::Dependency
|
34
34
|
name: bundler
|
35
35
|
requirement: !ruby/object:Gem::Requirement
|
@@ -92,7 +92,7 @@ homepage: https://github.com/rubysherpas/paranoia
|
|
92
92
|
licenses:
|
93
93
|
- MIT
|
94
94
|
metadata: {}
|
95
|
-
post_install_message:
|
95
|
+
post_install_message:
|
96
96
|
rdoc_options: []
|
97
97
|
require_paths:
|
98
98
|
- lib
|
@@ -107,8 +107,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
107
107
|
- !ruby/object:Gem::Version
|
108
108
|
version: 1.3.6
|
109
109
|
requirements: []
|
110
|
-
rubygems_version: 3.
|
111
|
-
signing_key:
|
110
|
+
rubygems_version: 3.1.2
|
111
|
+
signing_key:
|
112
112
|
specification_version: 4
|
113
113
|
summary: Paranoia is a re-implementation of acts_as_paranoid for Rails 3, 4, and 5,
|
114
114
|
using much, much, much less code.
|