2017-07-09 13:41:28 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
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
|
2014-10-27 12:28:53 -04:00
|
|
|
model_classes.each(&:clear_validators!)
|
2009-03-20 06:32:24 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2009-12-31 21:20:38 -05:00
|
|
|
def repair_validations(*model_classes)
|
2014-08-14 03:10:29 -04:00
|
|
|
yield if block_given?
|
2009-03-20 06:32:24 -04:00
|
|
|
ensure
|
2014-10-27 12:28:53 -04:00
|
|
|
model_classes.each(&:clear_validators!)
|
2009-03-20 06:32:24 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|