summaryrefslogtreecommitdiff
path: root/spec/lib/gitlab/database/async_indexes_spec.rb
blob: 74e30ea2c4e990c0cfbec5a4e156d1c4f83a3a23 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# frozen_string_literal: true

require 'spec_helper'

RSpec.describe Gitlab::Database::AsyncIndexes do
  describe '.create_pending_indexes!' do
    subject { described_class.create_pending_indexes! }

    before do
      create_list(:postgres_async_index, 4)
    end

    it 'takes 2 pending indexes and creates those' do
      Gitlab::Database::AsyncIndexes::PostgresAsyncIndex.order(:id).limit(2).each do |index|
        creator = double('index creator')
        expect(Gitlab::Database::AsyncIndexes::IndexCreator).to receive(:new).with(index).and_return(creator)
        expect(creator).to receive(:perform)
      end

      subject
    end
  end
end