paranoia 2.4.2 → 2.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.github/workflows/build.yml +56 -0
- data/CHANGELOG.md +14 -0
- data/Gemfile +1 -1
- data/README.md +2 -0
- data/lib/paranoia/version.rb +1 -1
- data/lib/paranoia.rb +12 -2
- data/paranoia.gemspec +3 -3
- data/test/paranoia_test.rb +15 -0
- metadata +13 -13
- data/.travis.yml +0 -39
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 722efe26008fec67396f31b78997d981323a85ded9232369e36b06f9c6a2c254
|
|
4
|
+
data.tar.gz: 4262aeee60d6beb99958ffe43032f47cab4b9ce556663daf7c6d9b34c9a17d7e
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 1e39832dc8d08052777e4c750a6481d4eb2280823561d2adfc6844426b7a23caf79eeb97fc9d98931da5f30142af0b241f6e3cc920ff82362bd5a605abc1b1f3
|
|
7
|
+
data.tar.gz: 684e92dc3ff1a24cd965ae4d03ef43b22e6ccc3c6a8cf73b41062d50d98568b1393ddfcc54a3f9e5630f65eba474b87ab202e03c9ca3613f82b470e434c5d12c
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
# This workflow uses actions that are not certified by GitHub.
|
|
2
|
+
# They are provided by a third-party and are governed by
|
|
3
|
+
# separate terms of service, privacy policy, and support
|
|
4
|
+
# documentation.
|
|
5
|
+
# This workflow will download a prebuilt Ruby version, install dependencies and run tests with Rake
|
|
6
|
+
# For more information see: https://github.com/marketplace/actions/setup-ruby-jruby-and-truffleruby
|
|
7
|
+
|
|
8
|
+
name: build
|
|
9
|
+
|
|
10
|
+
on: [push, pull_request]
|
|
11
|
+
|
|
12
|
+
jobs:
|
|
13
|
+
test:
|
|
14
|
+
runs-on: ubuntu-20.04
|
|
15
|
+
strategy:
|
|
16
|
+
fail-fast: false
|
|
17
|
+
matrix:
|
|
18
|
+
ruby:
|
|
19
|
+
# - 3.0 # incompatible with rubysl
|
|
20
|
+
- 2.7
|
|
21
|
+
- 2.6
|
|
22
|
+
- 2.5
|
|
23
|
+
# - jruby-9.2.19.0
|
|
24
|
+
# - jruby-9.3.1.0
|
|
25
|
+
rails:
|
|
26
|
+
- '~> 5.1.0'
|
|
27
|
+
- '~> 5.2.0'
|
|
28
|
+
- '~> 6.0.0'
|
|
29
|
+
- '~> 6.1.0'
|
|
30
|
+
- '~> 7.0.0'
|
|
31
|
+
- 'edge'
|
|
32
|
+
exclude:
|
|
33
|
+
# Rails edge is now 7.x and requires ruby 2.7
|
|
34
|
+
- rails: 'edge'
|
|
35
|
+
ruby: 2.6
|
|
36
|
+
- rails: 'edge'
|
|
37
|
+
ruby: 2.5
|
|
38
|
+
- rails: '~> 7.0.0'
|
|
39
|
+
ruby: 2.6
|
|
40
|
+
- rails: '~> 7.0.0'
|
|
41
|
+
ruby: 2.5
|
|
42
|
+
# Legacy Rails with newer rubies
|
|
43
|
+
- rails: '~> 5.1.0'
|
|
44
|
+
ruby: 3.0
|
|
45
|
+
- rails: '~> 5.2.0'
|
|
46
|
+
ruby: 3.0
|
|
47
|
+
|
|
48
|
+
env:
|
|
49
|
+
RAILS: ${{ matrix.rails }}
|
|
50
|
+
steps:
|
|
51
|
+
- uses: actions/checkout@v2
|
|
52
|
+
- uses: ruby/setup-ruby@v1
|
|
53
|
+
with:
|
|
54
|
+
ruby-version: ${{ matrix.ruby }}
|
|
55
|
+
bundler-cache: true
|
|
56
|
+
- run: bundle exec rake
|
data/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# paranoia Changelog
|
|
2
2
|
|
|
3
|
+
## 2.4.3
|
|
4
|
+
|
|
5
|
+
* [#503](https://github.com/rubysherpas/paranoia/pull/503) Bump activerecord dependency for Rails 6.1
|
|
6
|
+
|
|
7
|
+
[Jörg Schiller](https://github.com/joergschiller)
|
|
8
|
+
|
|
9
|
+
* [#483](https://github.com/rubysherpas/paranoia/pull/483) Update JRuby version to 9.2.8.0 + remove EOL Ruby 2.2
|
|
10
|
+
|
|
11
|
+
[Uwe Kubosch](https://github.com/donv)
|
|
12
|
+
|
|
13
|
+
* [#482](https://github.com/rubysherpas/paranoia/pull/482) Fix after_commit for Rails 6
|
|
14
|
+
|
|
15
|
+
[Ashwin Hegde](https://github.com/hashwin)
|
|
16
|
+
|
|
3
17
|
## 2.4.2
|
|
4
18
|
|
|
5
19
|
* [#470](https://github.com/rubysherpas/paranoia/pull/470) Add support for ActiveRecord 6.0
|
data/Gemfile
CHANGED
data/README.md
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
[](https://badge.fury.io/rb/paranoia)
|
|
2
|
+
|
|
1
3
|
**Notice:**
|
|
2
4
|
|
|
3
5
|
`paranoia` has some surprising behaviour (like overriding ActiveRecord's `delete` and `destroy`) and is not recommended for new projects. See [`discard`'s README](https://github.com/jhawthorn/discard#why-not-paranoia-or-acts_as_paranoid) for more details.
|
data/lib/paranoia/version.rb
CHANGED
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?
|
|
@@ -225,7 +230,12 @@ module Paranoia
|
|
|
225
230
|
end
|
|
226
231
|
end
|
|
227
232
|
|
|
228
|
-
|
|
233
|
+
if ActiveRecord.version.to_s > '7'
|
|
234
|
+
# Method deleted in https://github.com/rails/rails/commit/dd5886d00a2d5f31ccf504c391aad93deb014eb8
|
|
235
|
+
@association_cache.clear if persisted? && destroyed_associations.present?
|
|
236
|
+
else
|
|
237
|
+
clear_association_cache if destroyed_associations.present?
|
|
238
|
+
end
|
|
229
239
|
end
|
|
230
240
|
end
|
|
231
241
|
|
|
@@ -311,7 +321,7 @@ module ActiveRecord
|
|
|
311
321
|
def validate_each(record, attribute, value)
|
|
312
322
|
# if association is soft destroyed, add an error
|
|
313
323
|
if value.present? && value.paranoia_destroyed?
|
|
314
|
-
record.errors
|
|
324
|
+
record.errors.add(attribute, 'has been soft-deleted')
|
|
315
325
|
end
|
|
316
326
|
end
|
|
317
327
|
end
|
data/paranoia.gemspec
CHANGED
|
@@ -11,7 +11,7 @@ Gem::Specification.new do |s|
|
|
|
11
11
|
s.license = 'MIT'
|
|
12
12
|
s.summary = "Paranoia is a re-implementation of acts_as_paranoid for Rails 3, 4, and 5, using much, much, much less code."
|
|
13
13
|
s.description = <<-DSC
|
|
14
|
-
Paranoia is a re-implementation of acts_as_paranoid for Rails
|
|
14
|
+
Paranoia is a re-implementation of acts_as_paranoid for Rails 4, 5, 6, and 7,
|
|
15
15
|
using much, much, much less code. You would use either plugin / gem if you
|
|
16
16
|
wished that when you called destroy on an Active Record object that it
|
|
17
17
|
didn't actually destroy it, but just "hid" the record. Paranoia does this
|
|
@@ -22,9 +22,9 @@ Gem::Specification.new do |s|
|
|
|
22
22
|
|
|
23
23
|
s.required_rubygems_version = ">= 1.3.6"
|
|
24
24
|
|
|
25
|
-
s.required_ruby_version = '>= 2.
|
|
25
|
+
s.required_ruby_version = '>= 2.5'
|
|
26
26
|
|
|
27
|
-
s.add_dependency 'activerecord', '>=
|
|
27
|
+
s.add_dependency 'activerecord', '>= 5.1', '< 7.1'
|
|
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
|
+
version: 2.5.0
|
|
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: 2021-12-18 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: activerecord
|
|
@@ -16,20 +16,20 @@ dependencies:
|
|
|
16
16
|
requirements:
|
|
17
17
|
- - ">="
|
|
18
18
|
- !ruby/object:Gem::Version
|
|
19
|
-
version: '
|
|
19
|
+
version: '5.1'
|
|
20
20
|
- - "<"
|
|
21
21
|
- !ruby/object:Gem::Version
|
|
22
|
-
version: '
|
|
22
|
+
version: '7.1'
|
|
23
23
|
type: :runtime
|
|
24
24
|
prerelease: false
|
|
25
25
|
version_requirements: !ruby/object:Gem::Requirement
|
|
26
26
|
requirements:
|
|
27
27
|
- - ">="
|
|
28
28
|
- !ruby/object:Gem::Version
|
|
29
|
-
version: '
|
|
29
|
+
version: '5.1'
|
|
30
30
|
- - "<"
|
|
31
31
|
- !ruby/object:Gem::Version
|
|
32
|
-
version: '
|
|
32
|
+
version: '7.1'
|
|
33
33
|
- !ruby/object:Gem::Dependency
|
|
34
34
|
name: bundler
|
|
35
35
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -59,7 +59,7 @@ dependencies:
|
|
|
59
59
|
- !ruby/object:Gem::Version
|
|
60
60
|
version: '0'
|
|
61
61
|
description: |2
|
|
62
|
-
Paranoia is a re-implementation of acts_as_paranoid for Rails
|
|
62
|
+
Paranoia is a re-implementation of acts_as_paranoid for Rails 4, 5, 6, and 7,
|
|
63
63
|
using much, much, much less code. You would use either plugin / gem if you
|
|
64
64
|
wished that when you called destroy on an Active Record object that it
|
|
65
65
|
didn't actually destroy it, but just "hid" the record. Paranoia does this
|
|
@@ -73,8 +73,8 @@ executables: []
|
|
|
73
73
|
extensions: []
|
|
74
74
|
extra_rdoc_files: []
|
|
75
75
|
files:
|
|
76
|
+
- ".github/workflows/build.yml"
|
|
76
77
|
- ".gitignore"
|
|
77
|
-
- ".travis.yml"
|
|
78
78
|
- CHANGELOG.md
|
|
79
79
|
- CODE_OF_CONDUCT.md
|
|
80
80
|
- CONTRIBUTING.md
|
|
@@ -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
|
|
@@ -100,15 +100,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
100
100
|
requirements:
|
|
101
101
|
- - ">="
|
|
102
102
|
- !ruby/object:Gem::Version
|
|
103
|
-
version: '2.
|
|
103
|
+
version: '2.5'
|
|
104
104
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
105
105
|
requirements:
|
|
106
106
|
- - ">="
|
|
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.2.11
|
|
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.
|
data/.travis.yml
DELETED
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
sudo: false
|
|
2
|
-
language: ruby
|
|
3
|
-
before_install: gem update --system
|
|
4
|
-
cache: bundler
|
|
5
|
-
rvm:
|
|
6
|
-
- 2.2
|
|
7
|
-
- 2.3.8
|
|
8
|
-
- 2.4.5
|
|
9
|
-
- 2.5.3
|
|
10
|
-
- 2.6.3
|
|
11
|
-
- jruby-9.1.6.0
|
|
12
|
-
|
|
13
|
-
env:
|
|
14
|
-
matrix:
|
|
15
|
-
- RAILS='~> 4.2.0' SQLITE_VERSION='~> 1.3.6'
|
|
16
|
-
- RAILS='~> 5.0.0' SQLITE_VERSION='~> 1.3.6'
|
|
17
|
-
- RAILS='~> 5.1.0'
|
|
18
|
-
- RAILS='~> 5.2.0'
|
|
19
|
-
- RAILS='master'
|
|
20
|
-
|
|
21
|
-
matrix:
|
|
22
|
-
allow_failures:
|
|
23
|
-
- env: RAILS='~> 4.2.0' SQLITE_VERSION='~> 1.3.6'
|
|
24
|
-
rvm: jruby-9.1.6.0
|
|
25
|
-
- env: RAILS='~> 5.0.0' SQLITE_VERSION='~> 1.3.6'
|
|
26
|
-
rvm: jruby-9.1.6.0
|
|
27
|
-
- env: RAILS='~> 5.1.0'
|
|
28
|
-
rvm: jruby-9.1.6.0
|
|
29
|
-
- env: RAILS='~> 5.2.0'
|
|
30
|
-
rvm: jruby-9.1.6.0
|
|
31
|
-
- env: RAILS='master'
|
|
32
|
-
rvm: jruby-9.1.6.0
|
|
33
|
-
exclude:
|
|
34
|
-
- rvm: 2.2
|
|
35
|
-
env: RAILS='master'
|
|
36
|
-
- rvm: 2.3.8
|
|
37
|
-
env: RAILS='master'
|
|
38
|
-
- rvm: 2.4.5
|
|
39
|
-
env: RAILS='master'
|