aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases/repair_helper.rb
diff options
context:
space:
mode:
authorEmilio Tagua <miloops@gmail.com>2009-09-08 15:39:33 -0300
committerEmilio Tagua <miloops@gmail.com>2009-09-08 15:39:33 -0300
commit0489f0c582d2ab70595296f058545b102466bebd (patch)
tree159a85dda7bdb652c93cc05a7ab422283c9f3035 /activerecord/test/cases/repair_helper.rb
parent670281c6b2e9b9e8c51a140f2a5f66b251f1b84b (diff)
parentaf5b12c64c878f08336d38e91cc64137a30fb8da (diff)
downloadrails-0489f0c582d2ab70595296f058545b102466bebd.tar.gz
rails-0489f0c582d2ab70595296f058545b102466bebd.tar.bz2
rails-0489f0c582d2ab70595296f058545b102466bebd.zip
Merge commit 'rails/master'
Diffstat (limited to 'activerecord/test/cases/repair_helper.rb')
-rw-r--r--activerecord/test/cases/repair_helper.rb46
1 files changed, 0 insertions, 46 deletions
diff --git a/activerecord/test/cases/repair_helper.rb b/activerecord/test/cases/repair_helper.rb
deleted file mode 100644
index 80d04010d6..0000000000
--- a/activerecord/test/cases/repair_helper.rb
+++ /dev/null
@@ -1,46 +0,0 @@
-module ActiveRecord
- module Testing
- module RepairHelper
- extend ActiveSupport::Concern
-
- module Toolbox
- def self.record_validations(*model_classes)
- model_classes.inject({}) do |repair, klass|
- repair[klass] ||= {}
- [:validate, :validate_on_create, :validate_on_update].each do |callback|
- the_callback = klass.instance_variable_get("@#{callback.to_s}_callbacks")
- repair[klass][callback] = (the_callback.nil? ? nil : the_callback.dup)
- end
- repair
- end
- end
-
- def self.reset_validations(recorded)
- recorded.each do |klass, repairs|
- [:validate, :validate_on_create, :validate_on_update].each do |callback|
- klass.instance_variable_set("@#{callback.to_s}_callbacks", repairs[callback])
- end
- end
- end
- end
-
- module ClassMethods
- def repair_validations(*model_classes)
- setup do
- @validation_repairs = ActiveRecord::Testing::RepairHelper::Toolbox.record_validations(*model_classes)
- end
- teardown do
- ActiveRecord::Testing::RepairHelper::Toolbox.reset_validations(@validation_repairs)
- end
- end
- end
-
- def repair_validations(*model_classes, &block)
- validation_repairs = ActiveRecord::Testing::RepairHelper::Toolbox.record_validations(*model_classes)
- return block.call
- ensure
- ActiveRecord::Testing::RepairHelper::Toolbox.reset_validations(validation_repairs)
- end
- end
- end
-end