Commit 348b1c72 by Nikolay Norkin

Tests

parent 10f37a84
...@@ -451,6 +451,14 @@ class ParanoiaTest < test_framework ...@@ -451,6 +451,14 @@ class ParanoiaTest < test_framework
assert RelatedModel.unscoped.exists?(child_2.id) assert RelatedModel.unscoped.exists?(child_2.id)
end end
def test_really_destroy_behavior_for_callbacks
model = CallbackModel.new
model.save
model.really_destroy!
assert model.instance_variable_get(:@real_destroy_callback_called)
end
def test_really_delete def test_really_delete
model = ParanoidModel.new model = ParanoidModel.new
model.save model.save
...@@ -843,15 +851,16 @@ end ...@@ -843,15 +851,16 @@ end
class CallbackModel < ActiveRecord::Base class CallbackModel < ActiveRecord::Base
acts_as_paranoid acts_as_paranoid
before_destroy {|model| model.instance_variable_set :@destroy_callback_called, true } before_destroy { |model| model.instance_variable_set :@destroy_callback_called, true }
before_restore {|model| model.instance_variable_set :@restore_callback_called, true } before_restore { |model| model.instance_variable_set :@restore_callback_called, true }
before_update {|model| model.instance_variable_set :@update_callback_called, true } before_update { |model| model.instance_variable_set :@update_callback_called, true }
before_save {|model| model.instance_variable_set :@save_callback_called, true} before_save { |model| model.instance_variable_set :@save_callback_called, true}
before_real_destroy { |model| model.instance_variable_set :@real_destroy_callback_called, true }
after_destroy {|model| model.instance_variable_set :@after_destroy_callback_called, true } after_destroy { |model| model.instance_variable_set :@after_destroy_callback_called, true }
after_commit {|model| model.instance_variable_set :@after_commit_callback_called, true } after_commit { |model| model.instance_variable_set :@after_commit_callback_called, true }
validate {|model| model.instance_variable_set :@validate_called, true } validate { |model| model.instance_variable_set :@validate_called, true }
def remove_called_variables def remove_called_variables
instance_variables.each {|name| (name.to_s.end_with?('_called')) ? remove_instance_variable(name) : nil} instance_variables.each {|name| (name.to_s.end_with?('_called')) ? remove_instance_variable(name) : nil}
......
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