paranoia 2.3.1 → 2.5.3
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 +5 -5
- data/.github/workflows/build.yml +61 -0
- data/CHANGELOG.md +74 -0
- data/Gemfile +20 -8
- data/README.md +9 -0
- data/lib/paranoia/active_record_5_2.rb +41 -0
- data/lib/paranoia/rspec.rb +20 -17
- data/lib/paranoia/version.rb +1 -1
- data/lib/paranoia.rb +52 -35
- data/paranoia.gemspec +9 -4
- metadata +11 -12
- data/.travis.yml +0 -26
- data/test/paranoia_test.rb +0 -1361
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 5a82e404509dd15068040f391a794122bc66343af8def462f0eb4e37851b670f
|
4
|
+
data.tar.gz: fe04b171c8d485c18a4d41b2603780dfe15efebe1b3fd72d2a9074d0463642ae
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e797a325e51bd15605087eae81c27c622df6b2b3e2c46466b6a3d2f4509e612a3712871e4140abb0530993b6773f59765cab1c10672572f3176c7e32401ecaab
|
7
|
+
data.tar.gz: b040f4ea08e809a827172755f7913da31a93aa5a9f7207ac9626fa9dadf848e36b352eb7084687cbee3a553c7f33124e434d291c900ffca3cfbe1dba340d0fb3
|
@@ -0,0 +1,61 @@
|
|
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.1
|
20
|
+
- '3.0'
|
21
|
+
- 2.7
|
22
|
+
- 2.6
|
23
|
+
- 2.5
|
24
|
+
# - jruby-9.2.19.0
|
25
|
+
# - jruby-9.3.1.0
|
26
|
+
rails:
|
27
|
+
- '~> 5.1.0'
|
28
|
+
- '~> 5.2.0'
|
29
|
+
- '~> 6.0.0'
|
30
|
+
- '~> 6.1.0'
|
31
|
+
- '~> 7.0.0'
|
32
|
+
- 'edge'
|
33
|
+
exclude:
|
34
|
+
# Rails edge is now 7.x and requires ruby 2.7
|
35
|
+
- rails: 'edge'
|
36
|
+
ruby: 2.6
|
37
|
+
- rails: 'edge'
|
38
|
+
ruby: 2.5
|
39
|
+
- rails: '~> 7.0.0'
|
40
|
+
ruby: 2.6
|
41
|
+
- rails: '~> 7.0.0'
|
42
|
+
ruby: 2.5
|
43
|
+
# Legacy Rails with newer rubies
|
44
|
+
- rails: '~> 5.1.0'
|
45
|
+
ruby: '3.0'
|
46
|
+
- rails: '~> 5.2.0'
|
47
|
+
ruby: '3.0'
|
48
|
+
- rails: '~> 5.1.0'
|
49
|
+
ruby: 3.1
|
50
|
+
- rails: '~> 5.2.0'
|
51
|
+
ruby: 3.1
|
52
|
+
|
53
|
+
env:
|
54
|
+
RAILS: ${{ matrix.rails }}
|
55
|
+
steps:
|
56
|
+
- uses: actions/checkout@v2
|
57
|
+
- uses: ruby/setup-ruby@v1
|
58
|
+
with:
|
59
|
+
ruby-version: ${{ matrix.ruby }}
|
60
|
+
bundler-cache: true
|
61
|
+
- run: bundle exec rake
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,79 @@
|
|
1
1
|
# paranoia Changelog
|
2
2
|
|
3
|
+
## 2.5.3
|
4
|
+
|
5
|
+
* [#532](https://github.com/rubysherpas/paranoia/pull/532) Fix: correct bug when sentinel_value is not a timestamp
|
6
|
+
[Hassanin Ahmed](https://github.com/sas1ni69)
|
7
|
+
* [#531](https://github.com/rubysherpas/paranoia/pull/531) Added test case to reproduce bug introduce in v2.5.1
|
8
|
+
[Sherif Elkassaby](https://github.com/sherif-nedap)
|
9
|
+
* [#529](https://github.com/rubysherpas/paranoia/pull/529) Fix: Do not define a RSpec matcher when RSpec isn't present
|
10
|
+
[Sebastian Welther](https://github.com/swelther)
|
11
|
+
|
12
|
+
## 2.5.2
|
13
|
+
|
14
|
+
* [#526](https://github.com/rubysherpas/paranoia/pull/526) Do not include tests files in packaged gem
|
15
|
+
|
16
|
+
[Jason Fleetwood-Boldt](https://github.com/jasonfb)
|
17
|
+
* [#492](https://github.com/rubysherpas/paranoia/pull/492) Warn if acts_as_paranoid is called more than once on the same model
|
18
|
+
|
19
|
+
[Ignatius Reza](https://github.com/ignatiusreza)
|
20
|
+
|
21
|
+
## 2.5.1
|
22
|
+
|
23
|
+
* [#481](https://github.com/rubysherpas/paranoia/pull/481) Replaces hard coded `deleted_at` with `paranoia_column`.
|
24
|
+
|
25
|
+
[Hassanin Ahmed](https://github.com/sas1ni69)
|
26
|
+
|
27
|
+
## 2.5.0
|
28
|
+
|
29
|
+
* [#516](https://github.com/rubysherpas/paranoia/pull/516) Add support for ActiveRecord 7.0, drop support for EOL Ruby < 2.5 and Rails < 5.1
|
30
|
+
adding support for Rails 7
|
31
|
+
|
32
|
+
[Mathieu Jobin](https://github.com/mathieujobin)
|
33
|
+
* [#515](https://github.com/rubysherpas/paranoia/pull/515) Switch from Travis CI to GitHub Actions
|
34
|
+
|
35
|
+
[Shinichi Maeshima](https://github.com/willnet)
|
36
|
+
|
37
|
+
## 2.4.3
|
38
|
+
|
39
|
+
* [#503](https://github.com/rubysherpas/paranoia/pull/503) Bump activerecord dependency for Rails 6.1
|
40
|
+
|
41
|
+
[Jörg Schiller](https://github.com/joergschiller)
|
42
|
+
|
43
|
+
* [#483](https://github.com/rubysherpas/paranoia/pull/483) Update JRuby version to 9.2.8.0 + remove EOL Ruby 2.2
|
44
|
+
|
45
|
+
[Uwe Kubosch](https://github.com/donv)
|
46
|
+
|
47
|
+
* [#482](https://github.com/rubysherpas/paranoia/pull/482) Fix after_commit for Rails 6
|
48
|
+
|
49
|
+
[Ashwin Hegde](https://github.com/hashwin)
|
50
|
+
|
51
|
+
## 2.4.2
|
52
|
+
|
53
|
+
* [#470](https://github.com/rubysherpas/paranoia/pull/470) Add support for ActiveRecord 6.0
|
54
|
+
|
55
|
+
[Anton Kolodii](https://github.com/iggant), [Jared Norman](https://github.com/jarednorman)
|
56
|
+
|
57
|
+
## 2.4.1
|
58
|
+
|
59
|
+
* [#435](https://github.com/rubysherpas/paranoia/pull/435) Monkeypatch activerecord relations to work with rails 5.2.0
|
60
|
+
|
61
|
+
[Bartosz Bonisławski (@bbonislawski)](https://github.com/bbonislawski)
|
62
|
+
|
63
|
+
## 2.4.0
|
64
|
+
|
65
|
+
* [#423](https://github.com/rubysherpas/paranoia/pull/423) Add `paranoia_destroy` and `paranoia_delete` aliases
|
66
|
+
|
67
|
+
[John Hawthorn (@jhawthorn)](https://github.com/jhawthorn)
|
68
|
+
|
69
|
+
* [#408](https://github.com/rubysherpas/paranoia/pull/408) Fix instance variable `@_disable_counter_cache` not initialized warning.
|
70
|
+
|
71
|
+
[Akira Matsuda (@amatsuda)](https://github.com/amatsuda)
|
72
|
+
|
73
|
+
* [#412](https://github.com/rubysherpas/paranoia/pull/412) Fix `really_destroy!` behavior with `sentinel_value`
|
74
|
+
|
75
|
+
[Steve Rice (@steverice)](https://github.com/steverice)
|
76
|
+
|
3
77
|
## 2.3.1
|
4
78
|
|
5
79
|
* [#397](https://github.com/rubysherpas/paranoia/pull/397) Bump active record max version to support 5.1 final
|
data/Gemfile
CHANGED
@@ -1,20 +1,32 @@
|
|
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
|
-
gem 'activerecord-jdbcsqlite3-adapter'
|
12
|
+
gem 'activerecord-jdbcsqlite3-adapter'
|
7
13
|
end
|
8
14
|
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
15
|
+
if RUBY_ENGINE == 'rbx'
|
16
|
+
platforms :rbx do
|
17
|
+
gem 'rubinius-developer_tools'
|
18
|
+
gem 'rubysl', '~> 2.0'
|
19
|
+
gem 'rubysl-test-unit'
|
20
|
+
end
|
13
21
|
end
|
14
22
|
|
15
|
-
rails = ENV['RAILS'] || '~>
|
23
|
+
rails = ENV['RAILS'] || '~> 5.2.0'
|
16
24
|
|
17
|
-
|
25
|
+
if rails == 'edge'
|
26
|
+
gem 'rails', github: 'rails/rails'
|
27
|
+
else
|
28
|
+
gem 'rails', rails
|
29
|
+
end
|
18
30
|
|
19
31
|
# Specify your gem's dependencies in paranoia.gemspec
|
20
32
|
gemspec
|
data/README.md
CHANGED
@@ -1,3 +1,12 @@
|
|
1
|
+
[](https://badge.fury.io/rb/paranoia)
|
2
|
+
[](https://github.com/rubysherpas/paranoia/actions/workflows/build.yml)
|
3
|
+
|
4
|
+
**Notice:**
|
5
|
+
|
6
|
+
`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.
|
7
|
+
|
8
|
+
Paranoia will continue to accept bug fixes and support new versions of Rails but isn't accepting new features.
|
9
|
+
|
1
10
|
# Paranoia
|
2
11
|
|
3
12
|
Paranoia is a re-implementation of [acts\_as\_paranoid](http://github.com/ActsAsParanoid/acts_as_paranoid) for Rails 3/4/5, using much, much, much less code.
|
@@ -0,0 +1,41 @@
|
|
1
|
+
module HandleParanoiaDestroyedInBelongsToAssociation
|
2
|
+
def handle_dependency
|
3
|
+
return unless load_target
|
4
|
+
|
5
|
+
case options[:dependent]
|
6
|
+
when :destroy
|
7
|
+
target.destroy
|
8
|
+
if target.respond_to?(:paranoia_destroyed?)
|
9
|
+
raise ActiveRecord::Rollback unless target.paranoia_destroyed?
|
10
|
+
else
|
11
|
+
raise ActiveRecord::Rollback unless target.destroyed?
|
12
|
+
end
|
13
|
+
else
|
14
|
+
target.send(options[:dependent])
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
module HandleParanoiaDestroyedInHasOneAssociation
|
20
|
+
def delete(method = options[:dependent])
|
21
|
+
if load_target
|
22
|
+
case method
|
23
|
+
when :delete
|
24
|
+
target.delete
|
25
|
+
when :destroy
|
26
|
+
target.destroyed_by_association = reflection
|
27
|
+
target.destroy
|
28
|
+
if target.respond_to?(:paranoia_destroyed?)
|
29
|
+
throw(:abort) unless target.paranoia_destroyed?
|
30
|
+
else
|
31
|
+
throw(:abort) unless target.destroyed?
|
32
|
+
end
|
33
|
+
when :nullify
|
34
|
+
target.update_columns(reflection.foreign_key => nil) if target.persisted?
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
ActiveRecord::Associations::BelongsToAssociation.prepend HandleParanoiaDestroyedInBelongsToAssociation
|
41
|
+
ActiveRecord::Associations::HasOneAssociation.prepend HandleParanoiaDestroyedInHasOneAssociation
|
data/lib/paranoia/rspec.rb
CHANGED
@@ -1,23 +1,26 @@
|
|
1
|
-
|
1
|
+
if defined?(RSpec)
|
2
|
+
require 'rspec/expectations'
|
2
3
|
|
3
|
-
# Validate the subject's class did call "acts_as_paranoid"
|
4
|
-
RSpec::Matchers.define :act_as_paranoid do
|
5
|
-
|
4
|
+
# Validate the subject's class did call "acts_as_paranoid"
|
5
|
+
RSpec::Matchers.define :act_as_paranoid do
|
6
|
+
match { |subject| subject.class.ancestors.include?(Paranoia) }
|
6
7
|
|
7
|
-
|
8
|
-
|
9
|
-
|
8
|
+
failure_message_proc = lambda do
|
9
|
+
"expected #{subject.class} to use `acts_as_paranoid`"
|
10
|
+
end
|
10
11
|
|
11
|
-
|
12
|
-
|
13
|
-
|
12
|
+
failure_message_when_negated_proc = lambda do
|
13
|
+
"expected #{subject.class} not to use `acts_as_paranoid`"
|
14
|
+
end
|
14
15
|
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
16
|
+
if respond_to?(:failure_message_when_negated)
|
17
|
+
failure_message(&failure_message_proc)
|
18
|
+
failure_message_when_negated(&failure_message_when_negated_proc)
|
19
|
+
else
|
20
|
+
# RSpec 2 compatibility:
|
21
|
+
failure_message_for_should(&failure_message_proc)
|
22
|
+
failure_message_for_should_not(&failure_message_when_negated_proc)
|
23
|
+
end
|
22
24
|
end
|
25
|
+
|
23
26
|
end
|
data/lib/paranoia/version.rb
CHANGED
data/lib/paranoia.rb
CHANGED
@@ -1,5 +1,10 @@
|
|
1
1
|
require 'active_record' unless defined? ActiveRecord
|
2
2
|
|
3
|
+
if [ActiveRecord::VERSION::MAJOR, ActiveRecord::VERSION::MINOR] == [5, 2] ||
|
4
|
+
ActiveRecord::VERSION::MAJOR > 5
|
5
|
+
require 'paranoia/active_record_5_2'
|
6
|
+
end
|
7
|
+
|
3
8
|
module Paranoia
|
4
9
|
@@default_sentinel_value = nil
|
5
10
|
|
@@ -14,7 +19,6 @@ module Paranoia
|
|
14
19
|
|
15
20
|
def self.included(klazz)
|
16
21
|
klazz.extend Query
|
17
|
-
klazz.extend Callbacks
|
18
22
|
end
|
19
23
|
|
20
24
|
module Query
|
@@ -53,31 +57,11 @@ module Paranoia
|
|
53
57
|
end
|
54
58
|
end
|
55
59
|
|
56
|
-
|
57
|
-
def self.extended(klazz)
|
58
|
-
[:restore, :real_destroy].each do |callback_name|
|
59
|
-
klazz.define_callbacks callback_name
|
60
|
-
|
61
|
-
klazz.define_singleton_method("before_#{callback_name}") do |*args, &block|
|
62
|
-
set_callback(callback_name, :before, *args, &block)
|
63
|
-
end
|
64
|
-
|
65
|
-
klazz.define_singleton_method("around_#{callback_name}") do |*args, &block|
|
66
|
-
set_callback(callback_name, :around, *args, &block)
|
67
|
-
end
|
68
|
-
|
69
|
-
klazz.define_singleton_method("after_#{callback_name}") do |*args, &block|
|
70
|
-
set_callback(callback_name, :after, *args, &block)
|
71
|
-
end
|
72
|
-
end
|
73
|
-
end
|
74
|
-
end
|
75
|
-
|
76
|
-
def destroy
|
60
|
+
def paranoia_destroy
|
77
61
|
transaction do
|
78
62
|
run_callbacks(:destroy) do
|
79
63
|
@_disable_counter_cache = deleted?
|
80
|
-
result =
|
64
|
+
result = paranoia_delete
|
81
65
|
next result unless result && ActiveRecord::VERSION::STRING >= '4.2'
|
82
66
|
each_counter_cached_associations do |association|
|
83
67
|
foreign_key = association.reflection.foreign_key.to_sym
|
@@ -85,13 +69,24 @@ module Paranoia
|
|
85
69
|
next unless send(association.reflection.name)
|
86
70
|
association.decrement_counters
|
87
71
|
end
|
72
|
+
@_trigger_destroy_callback = true
|
88
73
|
@_disable_counter_cache = false
|
89
74
|
result
|
90
75
|
end
|
91
76
|
end
|
92
77
|
end
|
78
|
+
alias_method :destroy, :paranoia_destroy
|
79
|
+
|
80
|
+
def paranoia_destroy!
|
81
|
+
paranoia_destroy ||
|
82
|
+
raise(ActiveRecord::RecordNotDestroyed.new("Failed to destroy the record", self))
|
83
|
+
end
|
93
84
|
|
94
|
-
def
|
85
|
+
def trigger_transactional_callbacks?
|
86
|
+
super || @_trigger_destroy_callback && paranoia_destroyed?
|
87
|
+
end
|
88
|
+
|
89
|
+
def paranoia_delete
|
95
90
|
raise ActiveRecord::ReadOnlyRecord, "#{self.class} is marked as readonly" if readonly?
|
96
91
|
if persisted?
|
97
92
|
# if a transaction exists, add the record so that after_commit
|
@@ -103,6 +98,7 @@ module Paranoia
|
|
103
98
|
end
|
104
99
|
self
|
105
100
|
end
|
101
|
+
alias_method :delete, :paranoia_delete
|
106
102
|
|
107
103
|
def restore!(opts = {})
|
108
104
|
self.class.transaction do
|
@@ -112,7 +108,7 @@ module Paranoia
|
|
112
108
|
# This only happened on Rails versions earlier than 4.1.
|
113
109
|
noop_if_frozen = ActiveRecord.version < Gem::Version.new("4.1")
|
114
110
|
if within_recovery_window?(recovery_window_range) && ((noop_if_frozen && !@attributes.frozen?) || !noop_if_frozen)
|
115
|
-
@_disable_counter_cache = !
|
111
|
+
@_disable_counter_cache = !paranoia_destroyed?
|
116
112
|
write_attribute paranoia_column, paranoia_sentinel_value
|
117
113
|
update_columns(paranoia_restore_attributes)
|
118
114
|
each_counter_cached_associations do |association|
|
@@ -133,23 +129,23 @@ module Paranoia
|
|
133
129
|
def get_recovery_window_range(opts)
|
134
130
|
return opts[:recovery_window_range] if opts[:recovery_window_range]
|
135
131
|
return unless opts[:recovery_window]
|
136
|
-
(
|
132
|
+
(deletion_time - opts[:recovery_window]..deletion_time + opts[:recovery_window])
|
137
133
|
end
|
138
134
|
|
139
135
|
def within_recovery_window?(recovery_window_range)
|
140
136
|
return true unless recovery_window_range
|
141
|
-
recovery_window_range.cover?(
|
137
|
+
recovery_window_range.cover?(deletion_time)
|
142
138
|
end
|
143
139
|
|
144
140
|
def paranoia_destroyed?
|
145
|
-
|
141
|
+
paranoia_column_value != paranoia_sentinel_value
|
146
142
|
end
|
147
143
|
alias :deleted? :paranoia_destroyed?
|
148
144
|
|
149
145
|
def really_destroy!
|
150
146
|
transaction do
|
151
147
|
run_callbacks(:real_destroy) do
|
152
|
-
@_disable_counter_cache =
|
148
|
+
@_disable_counter_cache = paranoia_destroyed?
|
153
149
|
dependent_reflections = self.class.reflections.select do |name, reflection|
|
154
150
|
reflection.options[:dependent] == :destroy
|
155
151
|
end
|
@@ -165,7 +161,7 @@ module Paranoia
|
|
165
161
|
association_data.really_destroy!
|
166
162
|
end
|
167
163
|
end
|
168
|
-
|
164
|
+
update_columns(paranoia_destroy_attributes)
|
169
165
|
destroy_without_paranoia
|
170
166
|
end
|
171
167
|
end
|
@@ -174,7 +170,7 @@ module Paranoia
|
|
174
170
|
private
|
175
171
|
|
176
172
|
def each_counter_cached_associations
|
177
|
-
|
173
|
+
!(defined?(@_disable_counter_cache) && @_disable_counter_cache) ? super : []
|
178
174
|
end
|
179
175
|
|
180
176
|
def paranoia_restore_attributes
|
@@ -234,13 +230,26 @@ module Paranoia
|
|
234
230
|
end
|
235
231
|
end
|
236
232
|
|
237
|
-
|
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
|
238
239
|
end
|
239
240
|
end
|
240
241
|
|
241
242
|
ActiveSupport.on_load(:active_record) do
|
242
243
|
class ActiveRecord::Base
|
243
244
|
def self.acts_as_paranoid(options={})
|
245
|
+
if included_modules.include?(Paranoia)
|
246
|
+
puts "[WARN] #{self.name} is calling acts_as_paranoid more than once!"
|
247
|
+
|
248
|
+
return
|
249
|
+
end
|
250
|
+
|
251
|
+
define_model_callbacks :restore, :real_destroy
|
252
|
+
|
244
253
|
alias_method :really_destroyed?, :destroyed?
|
245
254
|
alias_method :really_delete, :delete
|
246
255
|
alias_method :destroy_without_paranoia, :destroy
|
@@ -287,9 +296,17 @@ ActiveSupport.on_load(:active_record) do
|
|
287
296
|
self.class.paranoia_column
|
288
297
|
end
|
289
298
|
|
299
|
+
def paranoia_column_value
|
300
|
+
send(paranoia_column)
|
301
|
+
end
|
302
|
+
|
290
303
|
def paranoia_sentinel_value
|
291
304
|
self.class.paranoia_sentinel_value
|
292
305
|
end
|
306
|
+
|
307
|
+
def deletion_time
|
308
|
+
paranoia_column_value.acts_like?(:time) ? paranoia_column_value : deleted_at
|
309
|
+
end
|
293
310
|
end
|
294
311
|
end
|
295
312
|
|
@@ -313,12 +330,12 @@ module ActiveRecord
|
|
313
330
|
class UniquenessValidator < ActiveModel::EachValidator
|
314
331
|
prepend UniquenessParanoiaValidator
|
315
332
|
end
|
316
|
-
|
333
|
+
|
317
334
|
class AssociationNotSoftDestroyedValidator < ActiveModel::EachValidator
|
318
335
|
def validate_each(record, attribute, value)
|
319
336
|
# if association is soft destroyed, add an error
|
320
|
-
if value.present? && value.
|
321
|
-
record.errors
|
337
|
+
if value.present? && value.paranoia_destroyed?
|
338
|
+
record.errors.add(attribute, 'has been soft-deleted')
|
322
339
|
end
|
323
340
|
end
|
324
341
|
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,14 +22,19 @@ 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"
|
31
31
|
|
32
|
-
|
32
|
+
|
33
|
+
s.files = Dir.chdir(File.expand_path('..', __FILE__)) do
|
34
|
+
files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)}) }
|
35
|
+
files
|
36
|
+
end
|
37
|
+
|
33
38
|
s.executables = `git ls-files`.split("\n").map{|f| f =~ /^bin\/(.*)/ ? $1 : nil}.compact
|
34
39
|
s.require_path = 'lib'
|
35
40
|
end
|
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.3
|
4
|
+
version: 2.5.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- radarlistener@gmail.com
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-03-23 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
|
@@ -83,10 +83,10 @@ files:
|
|
83
83
|
- README.md
|
84
84
|
- Rakefile
|
85
85
|
- lib/paranoia.rb
|
86
|
+
- lib/paranoia/active_record_5_2.rb
|
86
87
|
- lib/paranoia/rspec.rb
|
87
88
|
- lib/paranoia/version.rb
|
88
89
|
- paranoia.gemspec
|
89
|
-
- test/paranoia_test.rb
|
90
90
|
homepage: https://github.com/rubysherpas/paranoia
|
91
91
|
licenses:
|
92
92
|
- MIT
|
@@ -99,15 +99,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
99
99
|
requirements:
|
100
100
|
- - ">="
|
101
101
|
- !ruby/object:Gem::Version
|
102
|
-
version: '2.
|
102
|
+
version: '2.5'
|
103
103
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
104
104
|
requirements:
|
105
105
|
- - ">="
|
106
106
|
- !ruby/object:Gem::Version
|
107
107
|
version: 1.3.6
|
108
108
|
requirements: []
|
109
|
-
|
110
|
-
rubygems_version: 2.6.11
|
109
|
+
rubygems_version: 3.2.32
|
111
110
|
signing_key:
|
112
111
|
specification_version: 4
|
113
112
|
summary: Paranoia is a re-implementation of acts_as_paranoid for Rails 3, 4, and 5,
|
data/.travis.yml
DELETED
@@ -1,26 +0,0 @@
|
|
1
|
-
sudo: false
|
2
|
-
language: ruby
|
3
|
-
cache: bundler
|
4
|
-
rvm:
|
5
|
-
- 2.2.6
|
6
|
-
- 2.3.3
|
7
|
-
- 2.4.1
|
8
|
-
- jruby-9.1.6.0
|
9
|
-
|
10
|
-
env:
|
11
|
-
matrix:
|
12
|
-
- RAILS='~> 4.2.7.1'
|
13
|
-
- RAILS='~> 5.0.0.1'
|
14
|
-
- RAILS='~> 5.1.0.rc1'
|
15
|
-
|
16
|
-
matrix:
|
17
|
-
exclude:
|
18
|
-
- env: RAILS='~> 5.1.0.rc1'
|
19
|
-
rvm: 2.2.6
|
20
|
-
allow_failures:
|
21
|
-
- env: RAILS='~> 4.2.7.1'
|
22
|
-
rvm: jruby-9.1.6.0
|
23
|
-
- env: RAILS='~> 5.0.0.1'
|
24
|
-
rvm: jruby-9.1.6.0
|
25
|
-
- env: RAILS='~> 5.1.0.rc1'
|
26
|
-
rvm: jruby-9.1.6.0
|