Commit e03846fe by Rebecca Le Committed by GitHub

Merge branch 'core' into patch-1

parents 950a83fe ed86d01c
......@@ -69,6 +69,7 @@ module Paranoia
next unless send(association.reflection.name)
association.decrement_counters
end
@_trigger_destroy_callback = true
@_disable_counter_cache = false
result
end
......@@ -81,6 +82,10 @@ module Paranoia
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?
......
......@@ -131,6 +131,21 @@ class ParanoiaTest < test_framework
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
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment