debian-mirror-gitlab/spec/lib/gitlab/background_migration/backfill_namespace_traversal_ids_children_spec.rb
2021-06-08 01:23:25 +05:30

22 lines
903 B
Ruby

# frozen_string_literal: true
require 'spec_helper'
RSpec.describe Gitlab::BackgroundMigration::BackfillNamespaceTraversalIdsChildren, :migration, schema: 20210506065000 do
let(:namespaces_table) { table(:namespaces) }
let!(:user_namespace) { namespaces_table.create!(id: 1, name: 'user', path: 'user', type: nil) }
let!(:root_group) { namespaces_table.create!(id: 2, name: 'group', path: 'group', type: 'Group', parent_id: nil) }
let!(:sub_group) { namespaces_table.create!(id: 3, name: 'subgroup', path: 'subgroup', type: 'Group', parent_id: 2) }
describe '#perform' do
it 'backfills traversal_ids for child namespaces' do
described_class.new.perform(1, 3, 5)
expect(user_namespace.reload.traversal_ids).to eq([])
expect(root_group.reload.traversal_ids).to eq([])
expect(sub_group.reload.traversal_ids).to eq([root_group.id, sub_group.id])
end
end
end