2009-12-23 07:30:58 -05:00
|
|
|
module ActiveRecord
|
2009-03-20 06:32:24 -04:00
|
|
|
module ValidationsRepairHelper
|
2009-05-29 18:23:38 -04:00
|
|
|
extend ActiveSupport::Concern
|
2009-03-20 06:32:24 -04:00
|
|
|
|
|
|
|
module ClassMethods
|
|
|
|
def repair_validations(*model_classes)
|
|
|
|
teardown do
|
2009-09-08 11:10:14 -04:00
|
|
|
model_classes.each do |k|
|
2013-02-21 13:40:48 -05:00
|
|
|
k.clear_validators!
|
2009-09-08 11:10:14 -04:00
|
|
|
end
|
2009-03-20 06:32:24 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2009-12-31 21:20:38 -05:00
|
|
|
def repair_validations(*model_classes)
|
|
|
|
yield
|
2009-03-20 06:32:24 -04:00
|
|
|
ensure
|
2009-09-08 11:10:14 -04:00
|
|
|
model_classes.each do |k|
|
2013-02-21 13:40:48 -05:00
|
|
|
k.clear_validators!
|
2009-09-08 11:10:14 -04:00
|
|
|
end
|
2009-03-20 06:32:24 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|