Skip to content
This repository has been archived by the owner on Aug 3, 2023. It is now read-only.

Rails 6.1 #5

Merged
merged 23 commits into from
Dec 21, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
a4da86d
Fix after commit for rails 6
hashwin Nov 28, 2019
5b6be56
trigger_transactional_callbacks if paranoia destroyed
hashwin Nov 28, 2019
555ce03
Update JRuby version to 9.2.8.0 + avoid gem update
donv Dec 2, 2019
d493469
Reinstate gem update and remove EOL Ruby 2.2
donv Dec 2, 2019
594ec41
Removed extra whitespace
donv Dec 2, 2019
41f52c3
Avoid bundler 2 while testing Rails 4.2
donv Dec 2, 2019
d52c66e
Only update bundler if necessary
donv Dec 2, 2019
fd82642
Revert check for bundler >=2
donv Dec 3, 2019
c370a18
Uninstall global bundler
donv Dec 3, 2019
950a83f
Accept uninstall of executables
donv Dec 3, 2019
ed86d01
Merge pull request #482 from hashwin/hashwin/after_commit
sevenseacat Jun 29, 2020
e03846f
Merge branch 'core' into patch-1
sevenseacat Jun 29, 2020
00a7057
Merge pull request #483 from donv/patch-1
sevenseacat Jun 29, 2020
30f82f1
Bump activerecord dependency
joergschiller Dec 11, 2020
f504fc9
Avoid deprecated method to add error
joergschiller Dec 11, 2020
15a09a8
Merge pull request #503 from zinsbaustein/rails6.1
sevenseacat Dec 14, 2020
03d0779
Update version number
sevenseacat Dec 16, 2020
7c78f1f
Add changelog for v2.4.3
tricknotes Dec 17, 2020
07a64b5
Update supported Rails version in paranoia.gemspec
tricknotes Dec 17, 2020
858096b
Merge pull request #505 from tricknotes/add-changelog-for-2.4.3
sevenseacat Dec 17, 2020
552bc7d
Merge branch 'core' into update-description-in-gemspec
sevenseacat Dec 17, 2020
032a2ad
Merge pull request #506 from tricknotes/update-description-in-gemspec
sevenseacat Dec 17, 2020
b24d966
Merge remote-tracking branch 'upstream/core' into core
lrworth Dec 21, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,19 @@
# paranoia Changelog

## 2.4.4

* [#503](https://github.com/rubysherpas/paranoia/pull/503) Bump activerecord dependency for Rails 6.1

[Jörg Schiller](https://github.com/joergschiller)

* [#483](https://github.com/rubysherpas/paranoia/pull/483) Update JRuby version to 9.2.8.0 + remove EOL Ruby 2.2

[Uwe Kubosch](https://github.com/donv)

* [#482](https://github.com/rubysherpas/paranoia/pull/482) Fix after_commit for Rails 6

[Ashwin Hegde](https://github.com/hashwin)

## 2.4.3

* Fix deprecation message on Hash#with_indifferent_access
Expand Down
7 changes: 6 additions & 1 deletion lib/paranoia.rb
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ def paranoia_destroy
next unless send(association.reflection.name)
association.decrement_counters
end
@_trigger_destroy_callback = true
@_disable_counter_cache = false
result
end
Expand All @@ -121,6 +122,10 @@ def paranoia_destroy!
raise(ActiveRecord::RecordNotDestroyed.new("Failed to destroy the record", self))
end

def trigger_transactional_callbacks?
super || @_trigger_destroy_callback && paranoia_destroyed?
end

def paranoia_delete
raise ActiveRecord::ReadOnlyRecord, "#{self.class} is marked as readonly" if readonly?
if persisted?
Expand Down Expand Up @@ -351,7 +356,7 @@ class AssociationNotSoftDestroyedValidator < ActiveModel::EachValidator
def validate_each(record, attribute, value)
# if association is soft destroyed, add an error
if value.present? && value.paranoia_destroyed?
record.errors[attribute] << 'has been soft-deleted'
record.errors.add(attribute, 'has been soft-deleted')
end
end
end
Expand Down
4 changes: 2 additions & 2 deletions paranoia.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Gem::Specification.new do |s|
s.license = 'MIT'
s.summary = "Paranoia is a re-implementation of acts_as_paranoid for Rails 3, 4, and 5, using much, much, much less code."
s.description = <<-DSC
Paranoia is a re-implementation of acts_as_paranoid for Rails 3, 4, and 5,
Paranoia is a re-implementation of acts_as_paranoid for Rails 4, 5, and 6,
using much, much, much less code. You would use either plugin / gem if you
wished that when you called destroy on an Active Record object that it
didn't actually destroy it, but just "hid" the record. Paranoia does this
Expand All @@ -24,7 +24,7 @@ Gem::Specification.new do |s|

s.required_ruby_version = '>= 2.0'

s.add_dependency 'activerecord', '>= 4.0', '< 6.1'
s.add_dependency 'activerecord', '>= 4.0', '< 6.2'

s.add_development_dependency "bundler", ">= 1.0.0"
s.add_development_dependency "rake"
Expand Down
15 changes: 15 additions & 0 deletions test/paranoia_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,21 @@ def test_destroy_behavior_for_plain_models_callbacks
assert model.instance_variable_get(:@after_commit_callback_called)
end

def test_destroy_behavior_for_freshly_loaded_plain_models_callbacks
model = CallbackModel.new
model.save

model = CallbackModel.find(model.id)
model.destroy

assert_nil model.instance_variable_get(:@update_callback_called)
assert_nil model.instance_variable_get(:@save_callback_called)
assert_nil model.instance_variable_get(:@validate_called)

assert model.instance_variable_get(:@destroy_callback_called)
assert model.instance_variable_get(:@after_destroy_callback_called)
assert model.instance_variable_get(:@after_commit_callback_called)
end

def test_delete_behavior_for_plain_models_callbacks
model = CallbackModel.new
Expand Down