Welcome to mirror list, hosted at ThFree Co, Russian Federation.

cascade_check.rb « partitioning_testing « ci « models « helpers « support « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 7bcb8e5fcacba1dde3b687a31d1484d39bc66c5b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# frozen_string_literal: true

module PartitioningTesting
  module CascadeCheck
    extend ActiveSupport::Concern

    included do
      after_create :check_partition_cascade_value
    end

    def check_partition_cascade_value
      raise 'Partition value not found' unless partition_scope_value

      return if partition_id == partition_scope_value

      raise "partition_id was expected to equal #{partition_scope_value} but it was #{partition_id}."
    end

    class_methods do
      # Allowing partition callback to be used with BulkInsertSafe
      def _bulk_insert_callback_allowed?(name, args)
        super || (args.first == :after && args.second == :check_partition_cascade_value)
      end
    end
  end
end

Ci::Partitionable::Testing.partitionable_models.each do |klass|
  next if klass == 'Ci::Pipeline'

  model = klass.safe_constantize

  model.include(PartitioningTesting::CascadeCheck)
end