paranoia 2.4.1 → 2.4.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d25bfc4e0254aba4db5a58da8d666c68052e836bc2f315efbcd5ec2b77657b30
4
- data.tar.gz: d413ea576910faa0e4ebaff07c617c8692db837beeb24a5d5d43d0794170981f
3
+ metadata.gz: d0174a966648c3afbf8ce8d09ef65361c48540838e705bb3327477f36ee27eff
4
+ data.tar.gz: 70a9eb72fa2cfda78c4adf5aa9918404ad5860d725ac657959f0b105fd300276
5
5
  SHA512:
6
- metadata.gz: 354429a32eb5c97b1662456e56a5df64ff8b2c0d4ae02e57d528384eb33c17a161f5972275babfd55c279f7de54552073ae425c9a2c4b676a383ca55c83a8cfe
7
- data.tar.gz: 3f5e1914d1f200e82c8e1775bf2859e253b7aa6b434eaaf841276db9f017185f0f985ff7ef80ed53d103b1f21762419315568aa097a662946aab85db28431369
6
+ metadata.gz: 2a960433d0574c324778ae6774cc90501ee3a108c91e8aca45f91eeb59b1a80406b861b94e68b7fe391dc50c32fb7ebc034aa43296ec6ffd3bb78e863051a067
7
+ data.tar.gz: 765b1c436d256277a0ac54947584b90c69ffec5bad08011696e4a62267d1bf1e3b782957d904425933083b12e1fa3ce2668872acc83e04877304243ea96f9a61
@@ -1,28 +1,45 @@
1
1
  sudo: false
2
2
  language: ruby
3
- before_install: gem update --system
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
- - 2.3.5
8
- - 2.4.3
9
- - 2.5.0
10
- - jruby-9.1.6.0
8
+ - 2.3.8
9
+ - 2.4.5
10
+ - 2.5.3
11
+ - 2.6.3
12
+ - jruby-9.2.8.0
11
13
 
12
14
  env:
13
15
  matrix:
14
- - RAILS='~> 4.2.0'
15
- - RAILS='~> 5.0.0'
16
+ - RAILS='~> 4.2.0' SQLITE_VERSION='~> 1.3.6'
17
+ - RAILS='~> 5.0.0' SQLITE_VERSION='~> 1.3.6'
16
18
  - RAILS='~> 5.1.0'
17
19
  - RAILS='~> 5.2.0'
20
+ - RAILS='~> 6.1.0'
21
+ - RAILS='master'
18
22
 
19
23
  matrix:
20
24
  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='~> 4.2.0' SQLITE_VERSION='~> 1.3.6'
26
+ rvm: jruby-9.2.8.0
27
+ - env: RAILS='~> 5.0.0' SQLITE_VERSION='~> 1.3.6'
28
+ rvm: jruby-9.2.8.0
25
29
  - env: RAILS='~> 5.1.0'
26
- rvm: jruby-9.1.6.0
30
+ rvm: jruby-9.2.8.0
27
31
  - env: RAILS='~> 5.2.0'
28
- rvm: jruby-9.1.6.0
32
+ rvm: jruby-9.2.8.0
33
+ - env: RAILS='master'
34
+ rvm: jruby-9.2.8.0
35
+ - env: RAILS='~> 6.1.0'
36
+ rvm: jruby-9.2.8.0
37
+ exclude:
38
+ - rvm: 2.3.8
39
+ env: RAILS='master'
40
+ - rvm: 2.4.5
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'
@@ -1,8 +1,14 @@
1
1
  # paranoia Changelog
2
2
 
3
+ ## 2.4.2
4
+
5
+ * [#470](https://github.com/rubysherpas/paranoia/pull/470) Add support for ActiveRecord 6.0
6
+
7
+ [Anton Kolodii](https://github.com/iggant), [Jared Norman](https://github.com/jarednorman)
8
+
3
9
  ## 2.4.1
4
10
 
5
- * [#435](https://github.com/rubysherpas/paranoia/pull/435) Monkeypatch activerecord relations to work with rails 6.2.0
11
+ * [#435](https://github.com/rubysherpas/paranoia/pull/435) Monkeypatch activerecord relations to work with rails 5.2.0
6
12
 
7
13
  [Bartosz Bonisławski (@bbonislawski)](https://github.com/bbonislawski)
8
14
 
data/Gemfile CHANGED
@@ -1,20 +1,30 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
- gem 'sqlite3', platforms: [:ruby]
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
- gem 'rails', rails
23
+ if rails == 'master'
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
@@ -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?
@@ -305,12 +311,12 @@ module ActiveRecord
305
311
  class UniquenessValidator < ActiveModel::EachValidator
306
312
  prepend UniquenessParanoiaValidator
307
313
  end
308
-
314
+
309
315
  class AssociationNotSoftDestroyedValidator < ActiveModel::EachValidator
310
316
  def validate_each(record, attribute, value)
311
317
  # if association is soft destroyed, add an error
312
318
  if value.present? && value.paranoia_destroyed?
313
- record.errors[attribute] << 'has been soft-deleted'
319
+ record.errors.add(attribute, 'has been soft-deleted')
314
320
  end
315
321
  end
316
322
  end
@@ -1,3 +1,3 @@
1
1
  module Paranoia
2
- VERSION = '2.4.1'.freeze
2
+ VERSION = '2.4.3'.freeze
3
3
  end
@@ -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', '< 5.3'
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"
@@ -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.1
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: 2018-04-10 00:00:00.000000000 Z
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: '5.3'
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: '5.3'
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,9 +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
- rubyforge_project:
111
- rubygems_version: 2.7.6
112
- signing_key:
110
+ rubygems_version: 3.1.2
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.