diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-06-23 19:44:23 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-06-23 19:44:23 +0000 |
commit | 6b96d119aec0ba674cca2c380cf60f1500306612 (patch) | |
tree | f7742d802f557d04e2144b06a2b47719fbd58b82 /spec/services | |
parent | 8b7c4494871c7d69ac7bc59839bdce6ff2937f95 (diff) | |
download | gitlab-ce-6b96d119aec0ba674cca2c380cf60f1500306612.tar.gz |
Add latest changes from gitlab-org/gitlab@13-1-stable-ee
Diffstat (limited to 'spec/services')
-rw-r--r-- | spec/services/authorized_project_update/periodic_recalculate_service_spec.rb | 30 | ||||
-rw-r--r-- | spec/services/authorized_project_update/recalculate_for_user_range_service_spec.rb | 19 |
2 files changed, 49 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 diff --git a/spec/services/authorized_project_update/recalculate_for_user_range_service_spec.rb b/spec/services/authorized_project_update/recalculate_for_user_range_service_spec.rb new file mode 100644 index 00000000000..28cbda6f4fd --- /dev/null +++ b/spec/services/authorized_project_update/recalculate_for_user_range_service_spec.rb @@ -0,0 +1,19 @@ +# frozen_string_literal: true + +require 'spec_helper' + +describe AuthorizedProjectUpdate::RecalculateForUserRangeService do + describe '#execute' do + let_it_be(:users) { create_list(:user, 2) } + + it 'calls Users::RefreshAuthorizedProjectsService' do + users.each do |user| + expect(Users::RefreshAuthorizedProjectsService).to( + receive(:new).with(user).and_call_original) + end + + range = users.map(&:id).minmax + described_class.new(*range).execute + end + end +end |