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

                             
                   
                                
                                 
 

                                            
                   
                                                 



           
                                          
                           
          
                                             


       
# frozen_string_literal: true

module ActiveRecord
  module ValidationsRepairHelper
    extend ActiveSupport::Concern

    module ClassMethods
      def repair_validations(*model_classes)
        teardown do
          model_classes.each(&:clear_validators!)
        end
      end
    end

    def repair_validations(*model_classes)
      yield if block_given?
    ensure
      model_classes.each(&:clear_validators!)
    end
  end
end