aboutsummaryrefslogblamecommitdiffstats
path: root/activerecord/test/cases/validations_repair_helper.rb
blob: 2bbf0f23b34843b168d4eacd52fcb55a5078f56e (plain) (tree)
1
2
3
4
5
6
7
8
9
                   
                                
                                 
 

                                            
                   
                                   
                               
             



           
                                          
                           
          
                               
                           
         


       
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