summaryrefslogtreecommitdiff
path: root/spec/migrations/delete_internal_ids_where_feature_flags_usage_spec.rb
blob: 30d776c498b2720f3125163b31403773123eab06 (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
42
# frozen_string_literal: true

require 'spec_helper'
require_migration!

RSpec.describe DeleteInternalIdsWhereFeatureFlagsUsage do
  let(:namespaces)   { table(:namespaces) }
  let(:projects)     { table(:projects) }
  let(:internal_ids) { table(:internal_ids) }

  def setup
    namespace = namespaces.create!(name: 'foo', path: 'foo')
    projects.create!(namespace_id: namespace.id)
  end

  it 'deletes feature flag rows from the internal_ids table' do
    project = setup
    internal_ids.create!(project_id: project.id, usage: 6, last_value: 1)

    disable_migrations_output { migrate! }

    expect(internal_ids.count).to eq(0)
  end

  it 'does not delete issue rows from the internal_ids table' do
    project = setup
    internal_ids.create!(project_id: project.id, usage: 0, last_value: 1)

    disable_migrations_output { migrate! }

    expect(internal_ids.count).to eq(1)
  end

  it 'does not delete merge request rows from the internal_ids table' do
    project = setup
    internal_ids.create!(project_id: project.id, usage: 1, last_value: 1)

    disable_migrations_output { migrate! }

    expect(internal_ids.count).to eq(1)
  end
end