Commit 404b49a7 authored by Robert Speicher's avatar Robert Speicher

Bring CE-EE parity to migrations/remove_soft_removed_objects_spec.rb

parent f67eb5a1
......@@ -3,6 +3,18 @@ require Rails.root.join('db', 'post_migrate', '20171207150343_remove_soft_remove
describe RemoveSoftRemovedObjects, :migration do
describe '#up' do
let!(:groups) do
table(:namespaces).tap do |t|
t.inheritance_column = nil
end
end
let!(:routes) do
table(:routes).tap do |t|
t.inheritance_column = nil
end
end
it 'removes various soft removed objects' do
5.times do
create_with_deleted_at(:issue)
......@@ -28,19 +40,20 @@ describe RemoveSoftRemovedObjects, :migration do
it 'removes routes of soft removed personal namespaces' do
namespace = create_with_deleted_at(:namespace)
group = create(:group) # rubocop:disable RSpec/FactoriesInMigrationSpecs
group = groups.create!(name: 'group', path: 'group_path', type: 'Group')
routes.create!(source_id: group.id, source_type: 'Group', name: 'group', path: 'group_path')
expect(Route.where(source: namespace).exists?).to eq(true)
expect(Route.where(source: group).exists?).to eq(true)
expect(routes.where(source_id: namespace.id).exists?).to eq(true)
expect(routes.where(source_id: group.id).exists?).to eq(true)
run_migration
expect(Route.where(source: namespace).exists?).to eq(false)
expect(Route.where(source: group).exists?).to eq(true)
expect(routes.where(source_id: namespace.id).exists?).to eq(false)
expect(routes.where(source_id: group.id).exists?).to eq(true)
end
it 'schedules the removal of soft removed groups' do
group = create_with_deleted_at(:group)
group = create_deleted_group
admin = create(:user, admin: true) # rubocop:disable RSpec/FactoriesInMigrationSpecs
expect_any_instance_of(GroupDestroyWorker)
......@@ -51,7 +64,7 @@ describe RemoveSoftRemovedObjects, :migration do
end
it 'does not remove soft removed groups when no admin user could be found' do
create_with_deleted_at(:group)
create_deleted_group
expect_any_instance_of(GroupDestroyWorker)
.not_to receive(:perform)
......@@ -74,4 +87,13 @@ describe RemoveSoftRemovedObjects, :migration do
row
end
def create_deleted_group
group = groups.create!(name: 'group', path: 'group_path', type: 'Group')
routes.create!(source_id: group.id, source_type: 'Group', name: 'group', path: 'group_path')
groups.where(id: group.id).update_all(deleted_at: 1.year.ago)
group
end
end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment