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
Akira Matsuda e76379b04a Clear validators before and after each test
Or some tests fail when run in random order
2014-08-14 16:14:02 +09:00

23 lines
460 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 if block_given?
ensure
model_classes.each do |k|
k.clear_validators!
end
end
end
end