aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases/validations_repair_helper.rb
blob: 11912ca1cc52fe22ca4d033e6e65ba02f09b90e2 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
module ActiveRecord
  module ValidationsRepairHelper
    extend ActiveSupport::Concern

    module ClassMethods
      def repair_validations(*model_classes)
        teardown do
          model_classes.each do |k|
            k.reset_callbacks(:validate)
          end
        end
      end
    end

    def repair_validations(*model_classes)
      yield
    ensure
      model_classes.each do |k|
        k.reset_callbacks(:validate)
      end
    end
  end
end