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

remove_invalid_integrations_spec.rb « migrations « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: cab2d79998e000e55ca2add3cbabec7fd596be47 (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
# frozen_string_literal: true

require 'spec_helper'
require_migration!

RSpec.describe RemoveInvalidIntegrations, :migration do
  describe '#up' do
    let!(:integrations) { table(:integrations) }

    let!(:valid_integration) { integrations.create!(type_new: 'Foo') }
    let!(:invalid_integration) { integrations.create! }

    it 'removes invalid integrations', :aggregate_failures do
      expect { migrate! }
        .to change { integrations.pluck(:id) }.to(contain_exactly(valid_integration.id))
    end

    context 'when there are many invalid integrations' do
      before do
        stub_const('RemoveInvalidIntegrations::BATCH_SIZE', 3)
        5.times { integrations.create! }
      end

      it 'removes them all' do
        migrate!

        expect(integrations.pluck(:type_new)).to all(be_present)
      end
    end
  end
end