blob: e5f64ef2e7015c9da3feba96f50301562718317a (
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 RemoveUserNamespaceRecordsFromVsaAggregation,
migration: :gitlab_main,
feature_category: :value_stream_management do
let(:migration) { described_class::MIGRATION }
let!(:namespaces) { table(:namespaces) }
let!(:aggregations) { table(:analytics_cycle_analytics_aggregations) }
let!(:group) { namespaces.create!(name: 'aaa', path: 'aaa', type: 'Group') }
let!(:user_namespace) { namespaces.create!(name: 'ccc', path: 'ccc', type: 'User') }
let!(:project_namespace) { namespaces.create!(name: 'bbb', path: 'bbb', type: 'Project') }
let!(:group_aggregation) { aggregations.create!(group_id: group.id) }
let!(:user_namespace_aggregation) { aggregations.create!(group_id: user_namespace.id) }
let!(:project_namespace_aggregation) { aggregations.create!(group_id: project_namespace.id) }
describe '#up' do
it 'deletes the non-group namespace aggregation records' do
stub_const('RemoveUserNamespaceRecordsFromVsaAggregation::BATCH_SIZE', 1)
expect { migrate! }.to change {
aggregations.order(:group_id)
}.from([group_aggregation, user_namespace_aggregation,
project_namespace_aggregation]).to([group_aggregation])
end
end
describe '#down' do
it 'does nothing' do
migrate!
expect { schema_migrate_down! }.not_to change {
aggregations.order(:group_id).pluck(:group_id)
}.from([group_aggregation.id])
end
end
end
|