1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00
rails--rails/activerecord/test/cases/validations_repair_helper.rb
wangjohn 3ee30ca44a The repair_validations helper was not working correctly before because
it only cleared the validations that created :validate callbacks. This
didn't include the validates created by validates_with, so I've added a
method to clear all validations.
2013-03-19 12:23:20 -04:00

23 lines
444 B
Ruby

module ActiveRecord
module ValidationsRepairHelper
extend ActiveSupport::Concern
module ClassMethods
def repair_validations(*model_classes)
teardown do
model_classes.each do |k|
k.clear_validators!
end
end
end
end
def repair_validations(*model_classes)
yield
ensure
model_classes.each do |k|
k.clear_validators!
end
end
end
end