paranoia 2.4.1 → 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 +21 -1
- data/Gemfile +13 -3
- data/README.md +2 -0
- data/lib/paranoia/version.rb +1 -1
- data/lib/paranoia.rb +15 -4
- data/paranoia.gemspec +3 -3
- data/test/paranoia_test.rb +15 -0
- metadata +13 -14
- data/.travis.yml +0 -28
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,8 +1,28 @@
|
|
|
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
|
+
|
|
17
|
+
## 2.4.2
|
|
18
|
+
|
|
19
|
+
* [#470](https://github.com/rubysherpas/paranoia/pull/470) Add support for ActiveRecord 6.0
|
|
20
|
+
|
|
21
|
+
[Anton Kolodii](https://github.com/iggant), [Jared Norman](https://github.com/jarednorman)
|
|
22
|
+
|
|
3
23
|
## 2.4.1
|
|
4
24
|
|
|
5
|
-
* [#435](https://github.com/rubysherpas/paranoia/pull/435) Monkeypatch activerecord relations to work with rails
|
|
25
|
+
* [#435](https://github.com/rubysherpas/paranoia/pull/435) Monkeypatch activerecord relations to work with rails 5.2.0
|
|
6
26
|
|
|
7
27
|
[Bartosz Bonisławski (@bbonislawski)](https://github.com/bbonislawski)
|
|
8
28
|
|
data/Gemfile
CHANGED
|
@@ -1,20 +1,30 @@
|
|
|
1
1
|
source 'https://rubygems.org'
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
sqlite = ENV['SQLITE_VERSION']
|
|
4
|
+
|
|
5
|
+
if sqlite
|
|
6
|
+
gem 'sqlite3', sqlite, platforms: [:ruby]
|
|
7
|
+
else
|
|
8
|
+
gem 'sqlite3', platforms: [:ruby]
|
|
9
|
+
end
|
|
4
10
|
|
|
5
11
|
platforms :jruby do
|
|
6
12
|
gem 'activerecord-jdbcsqlite3-adapter'
|
|
7
13
|
end
|
|
8
14
|
|
|
9
15
|
platforms :rbx do
|
|
16
|
+
gem 'rubinius-developer_tools'
|
|
10
17
|
gem 'rubysl', '~> 2.0'
|
|
11
18
|
gem 'rubysl-test-unit'
|
|
12
|
-
gem 'rubinius-developer_tools'
|
|
13
19
|
end
|
|
14
20
|
|
|
15
21
|
rails = ENV['RAILS'] || '~> 5.2.0'
|
|
16
22
|
|
|
17
|
-
|
|
23
|
+
if rails == 'edge'
|
|
24
|
+
gem 'rails', github: 'rails/rails'
|
|
25
|
+
else
|
|
26
|
+
gem 'rails', rails
|
|
27
|
+
end
|
|
18
28
|
|
|
19
29
|
# Specify your gem's dependencies in paranoia.gemspec
|
|
20
30
|
gemspec
|
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
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
require 'active_record' unless defined? ActiveRecord
|
|
2
2
|
|
|
3
|
-
if [ActiveRecord::VERSION::MAJOR, ActiveRecord::VERSION::MINOR] == [5, 2]
|
|
3
|
+
if [ActiveRecord::VERSION::MAJOR, ActiveRecord::VERSION::MINOR] == [5, 2] ||
|
|
4
|
+
ActiveRecord::VERSION::MAJOR > 5
|
|
4
5
|
require 'paranoia/active_record_5_2'
|
|
5
6
|
end
|
|
6
7
|
|
|
@@ -68,6 +69,7 @@ module Paranoia
|
|
|
68
69
|
next unless send(association.reflection.name)
|
|
69
70
|
association.decrement_counters
|
|
70
71
|
end
|
|
72
|
+
@_trigger_destroy_callback = true
|
|
71
73
|
@_disable_counter_cache = false
|
|
72
74
|
result
|
|
73
75
|
end
|
|
@@ -80,6 +82,10 @@ module Paranoia
|
|
|
80
82
|
raise(ActiveRecord::RecordNotDestroyed.new("Failed to destroy the record", self))
|
|
81
83
|
end
|
|
82
84
|
|
|
85
|
+
def trigger_transactional_callbacks?
|
|
86
|
+
super || @_trigger_destroy_callback && paranoia_destroyed?
|
|
87
|
+
end
|
|
88
|
+
|
|
83
89
|
def paranoia_delete
|
|
84
90
|
raise ActiveRecord::ReadOnlyRecord, "#{self.class} is marked as readonly" if readonly?
|
|
85
91
|
if persisted?
|
|
@@ -224,7 +230,12 @@ module Paranoia
|
|
|
224
230
|
end
|
|
225
231
|
end
|
|
226
232
|
|
|
227
|
-
|
|
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
|
|
228
239
|
end
|
|
229
240
|
end
|
|
230
241
|
|
|
@@ -305,12 +316,12 @@ module ActiveRecord
|
|
|
305
316
|
class UniquenessValidator < ActiveModel::EachValidator
|
|
306
317
|
prepend UniquenessParanoiaValidator
|
|
307
318
|
end
|
|
308
|
-
|
|
319
|
+
|
|
309
320
|
class AssociationNotSoftDestroyedValidator < ActiveModel::EachValidator
|
|
310
321
|
def validate_each(record, attribute, value)
|
|
311
322
|
# if association is soft destroyed, add an error
|
|
312
323
|
if value.present? && value.paranoia_destroyed?
|
|
313
|
-
record.errors
|
|
324
|
+
record.errors.add(attribute, 'has been soft-deleted')
|
|
314
325
|
end
|
|
315
326
|
end
|
|
316
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,16 +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
|
-
|
|
111
|
-
|
|
112
|
-
signing_key:
|
|
110
|
+
rubygems_version: 3.2.11
|
|
111
|
+
signing_key:
|
|
113
112
|
specification_version: 4
|
|
114
113
|
summary: Paranoia is a re-implementation of acts_as_paranoid for Rails 3, 4, and 5,
|
|
115
114
|
using much, much, much less code.
|
data/.travis.yml
DELETED
|
@@ -1,28 +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.5
|
|
8
|
-
- 2.4.3
|
|
9
|
-
- 2.5.0
|
|
10
|
-
- jruby-9.1.6.0
|
|
11
|
-
|
|
12
|
-
env:
|
|
13
|
-
matrix:
|
|
14
|
-
- RAILS='~> 4.2.0'
|
|
15
|
-
- RAILS='~> 5.0.0'
|
|
16
|
-
- RAILS='~> 5.1.0'
|
|
17
|
-
- RAILS='~> 5.2.0'
|
|
18
|
-
|
|
19
|
-
matrix:
|
|
20
|
-
allow_failures:
|
|
21
|
-
- env: RAILS='~> 4.2.0'
|
|
22
|
-
rvm: jruby-9.1.6.0
|
|
23
|
-
- env: RAILS='~> 5.0.0'
|
|
24
|
-
rvm: jruby-9.1.6.0
|
|
25
|
-
- env: RAILS='~> 5.1.0'
|
|
26
|
-
rvm: jruby-9.1.6.0
|
|
27
|
-
- env: RAILS='~> 5.2.0'
|
|
28
|
-
rvm: jruby-9.1.6.0
|