diff options
Diffstat (limited to 'spec/services/authorized_project_update/periodic_recalculate_service_spec.rb')
-rw-r--r-- | spec/services/authorized_project_update/periodic_recalculate_service_spec.rb | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/spec/services/authorized_project_update/periodic_recalculate_service_spec.rb b/spec/services/authorized_project_update/periodic_recalculate_service_spec.rb new file mode 100644 index 00000000000..020056da36e --- /dev/null +++ b/spec/services/authorized_project_update/periodic_recalculate_service_spec.rb @@ -0,0 +1,30 @@ +# frozen_string_literal: true + +require 'spec_helper' + +describe AuthorizedProjectUpdate::PeriodicRecalculateService do + subject(:service) { described_class.new } + + describe '#execute' do + let(:batch_size) { 2 } + + let_it_be(:users) { create_list(:user, 4) } + + before do + stub_const('AuthorizedProjectUpdate::PeriodicRecalculateService::BATCH_SIZE', batch_size) + + User.delete([users[1], users[2]]) + end + + it 'calls AuthorizedProjectUpdate::UserRefreshOverUserRangeWorker' do + (1..User.maximum(:id)).each_slice(batch_size).with_index do |batch, index| + delay = AuthorizedProjectUpdate::PeriodicRecalculateService::DELAY_INTERVAL * index + + expect(AuthorizedProjectUpdate::UserRefreshOverUserRangeWorker).to( + receive(:perform_in).with(delay, *batch.minmax)) + end + + service.execute + end + end +end |