diff options
Diffstat (limited to 'spec/workers/authorized_project_update/user_refresh_over_user_range_worker_spec.rb')
-rw-r--r-- | spec/workers/authorized_project_update/user_refresh_over_user_range_worker_spec.rb | 63 |
1 files changed, 15 insertions, 48 deletions
diff --git a/spec/workers/authorized_project_update/user_refresh_over_user_range_worker_spec.rb b/spec/workers/authorized_project_update/user_refresh_over_user_range_worker_spec.rb index 925e7f96eee..7c0c4d5bab4 100644 --- a/spec/workers/authorized_project_update/user_refresh_over_user_range_worker_spec.rb +++ b/spec/workers/authorized_project_update/user_refresh_over_user_range_worker_spec.rb @@ -12,70 +12,37 @@ RSpec.describe AuthorizedProjectUpdate::UserRefreshOverUserRangeWorker do it_behaves_like 'worker with data consistency', described_class, - feature_flag: :delayed_consistency_for_user_refresh_over_range_worker, data_consistency: :delayed describe '#perform' do - context 'when the feature flag `periodic_project_authorization_update_via_replica` is enabled' do - before do - stub_feature_flags(periodic_project_authorization_update_via_replica: true) - end - - context 'checks if project authorization update is required' do - it 'checks if a project_authorization refresh is needed for each of the users' do - User.where(id: start_user_id..end_user_id).each do |user| - expect(AuthorizedProjectUpdate::FindRecordsDueForRefreshService).to( - receive(:new).with(user).and_call_original) - end - - execute_worker - end - end - - context 'when there are project authorization records due for either removal or addition for a specific user' do - before do - user.project_authorizations.delete_all - end - - it 'enqueues a new project authorization update job for the user' do - expect(AuthorizedProjectUpdate::UserRefreshWithLowUrgencyWorker).to receive(:perform_async).with(user.id) - - execute_worker + context 'checks if project authorization update is required' do + it 'checks if a project_authorization refresh is needed for each of the users' do + User.where(id: start_user_id..end_user_id).each do |user| + expect(AuthorizedProjectUpdate::FindRecordsDueForRefreshService).to( + receive(:new).with(user).and_call_original) end - end - - context 'when there are no additions or removals to be made to project authorizations for a specific user' do - it 'does not enqueue a new project authorization update job for the user' do - expect(AuthorizedProjectUpdate::UserRefreshWithLowUrgencyWorker).not_to receive(:perform_async) - execute_worker - end + execute_worker end end - context 'when the feature flag `periodic_project_authorization_update_via_replica` is disabled' do + context 'when there are project authorization records due for either removal or addition for a specific user' do before do - stub_feature_flags(periodic_project_authorization_update_via_replica: false) + user.project_authorizations.delete_all end - it 'calls AuthorizedProjectUpdate::RecalculateForUserRangeService' do - expect_next_instance_of(AuthorizedProjectUpdate::RecalculateForUserRangeService, start_user_id, end_user_id) do |service| - expect(service).to receive(:execute) - end + it 'enqueues a new project authorization update job for the user' do + expect(AuthorizedProjectUpdate::UserRefreshWithLowUrgencyWorker).to receive(:perform_async).with(user.id) execute_worker end + end - context 'when load balancing is enabled' do - before do - allow(Gitlab::Database::LoadBalancing).to receive(:enable?).and_return(true) - end - - it 'reads from the primary database' do - expect(Gitlab::Database::LoadBalancing::Session.current).to receive(:use_primary!) + context 'when there are no additions or removals to be made to project authorizations for a specific user' do + it 'does not enqueue a new project authorization update job for the user' do + expect(AuthorizedProjectUpdate::UserRefreshWithLowUrgencyWorker).not_to receive(:perform_async) - execute_worker - end + execute_worker end end end |