Commit be71608c authored by Stan Hu's avatar Stan Hu

Make namespace deletions log an event per project deletion

parent 088a401f
module Groups
class DestroyService < Groups::BaseService
def async_execute
# Soft delete via paranoia gem
group.destroy
# Don't call `group.destroy` since this will purge all the projects, which may be too slow
group.deleted_at = Time.now
job_id = GroupDestroyWorker.perform_async(group.id, current_user.id)
Rails.logger.info("User #{current_user.id} scheduled a deletion of group ID #{group.id} with job ID #{job_id}")
end
......
......@@ -10,10 +10,17 @@ describe Groups::DestroyService, services: true do
group.add_user(user, Gitlab::Access::OWNER)
end
it 'creates a Geo event log for each project deleted' do
it 'creates a Geo event log when project is deleted synchronously' do
Groups::DestroyService.new(group, user).execute
expect(Geo::EventLog.count).to eq(1)
expect(Geo::RepositoryDeletedEvent.count).to eq(1)
end
it 'creates a Geo event log when project is deleted asynchronously' do
Sidekiq::Testing.inline! { Groups::DestroyService.new(group, user).async_execute }
expect(Geo::EventLog.count).to eq(1)
expect(Geo::RepositoryDeletedEvent.count).to eq(1)
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