gitlab-org--gitlab-foss/spec/services/users/migrate_records_to_ghost_us...

32 lines
886 B
Ruby

# frozen_string_literal: true
require 'spec_helper'
RSpec.describe Users::MigrateRecordsToGhostUserInBatchesService do
let(:service) { described_class.new }
let_it_be(:ghost_user_migration) { create(:ghost_user_migration) }
describe '#execute' do
it 'stops when execution time limit reached' do
expect_next_instance_of(::Gitlab::Utils::ExecutionTracker) do |tracker|
expect(tracker).to receive(:over_limit?).and_return(true)
end
expect(Users::MigrateRecordsToGhostUserService).not_to receive(:new)
service.execute
end
it 'calls Users::MigrateRecordsToGhostUserService' do
expect_next_instance_of(Users::MigrateRecordsToGhostUserService) do |service|
expect(service).to(
receive(:execute)
.with(hard_delete: ghost_user_migration.hard_delete))
end
service.execute
end
end
end