diff options
author | José Valim <jose.valim@gmail.com> | 2010-01-01 03:20:38 +0100 |
---|---|---|
committer | José Valim <jose.valim@gmail.com> | 2010-01-01 03:20:38 +0100 |
commit | 8c5fe60ec82986ab4aa337a69c2ab753f518976d (patch) | |
tree | 13ac7474bd3da7b26d7aef896bf98951bffdeeee /activerecord/test/cases/validations_repair_helper.rb | |
parent | 50fbb7405665ba1c2b7c6f23574053a4764cef7f (diff) | |
download | rails-8c5fe60ec82986ab4aa337a69c2ab753f518976d.tar.gz rails-8c5fe60ec82986ab4aa337a69c2ab753f518976d.tar.bz2 rails-8c5fe60ec82986ab4aa337a69c2ab753f518976d.zip |
Simplify repair_validations on AR and make it work with new callbacks.
Diffstat (limited to 'activerecord/test/cases/validations_repair_helper.rb')
-rw-r--r-- | activerecord/test/cases/validations_repair_helper.rb | 20 |
1 files changed, 4 insertions, 16 deletions
diff --git a/activerecord/test/cases/validations_repair_helper.rb b/activerecord/test/cases/validations_repair_helper.rb index e04738d209..11912ca1cc 100644 --- a/activerecord/test/cases/validations_repair_helper.rb +++ b/activerecord/test/cases/validations_repair_helper.rb @@ -4,31 +4,19 @@ module ActiveRecord module ClassMethods def repair_validations(*model_classes) - setup do - @_stored_callbacks = {} - model_classes.each do |k| - @_stored_callbacks[k] = k._validate_callbacks.dup - end - end teardown do model_classes.each do |k| - k._validate_callbacks = @_stored_callbacks[k] - k.__update_callbacks(:validate) + k.reset_callbacks(:validate) end end end end - def repair_validations(*model_classes, &block) - @__stored_callbacks = {} - model_classes.each do |k| - @__stored_callbacks[k] = k._validate_callbacks.dup - end - return block.call + def repair_validations(*model_classes) + yield ensure model_classes.each do |k| - k._validate_callbacks = @__stored_callbacks[k] - k.__update_callbacks(:validate) + k.reset_callbacks(:validate) end end end |