summaryrefslogtreecommitdiff
path: root/spec/migrations/backport_enterprise_schema_spec.rb
blob: de6821001b4a4f467d913074538a517550e1dbb8 (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
35
36
37
38
39
40
41
# frozen_string_literal: true

require 'spec_helper'

require_migration!

RSpec.describe BackportEnterpriseSchema, schema: 20190329085614 do
  include MigrationsHelpers

  def drop_if_exists(table)
    active_record_base.connection.drop_table(table) if active_record_base.connection.table_exists?(table)
  end

  describe '#up' do
    it 'creates new EE tables' do
      migrate!

      expect(active_record_base.connection.table_exists?(:epics)).to be true
      expect(active_record_base.connection.table_exists?(:geo_nodes)).to be true
    end

    context 'missing EE columns' do
      before do
        drop_if_exists(:epics)

        active_record_base.connection.create_table "epics" do |t|
          t.integer :group_id, null: false, index: true
          t.integer :author_id, null: false, index: true
        end
      end

      after do
        drop_if_exists(:epics)
      end

      it 'flags an error' do
        expect { migrate! }.to raise_error(/Your database is missing.*that is present for GitLab EE/)
      end
    end
  end
end