Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'spec/services/projects/group_links')
-rw-r--r--spec/services/projects/group_links/create_service_spec.rb24
-rw-r--r--spec/services/projects/group_links/destroy_service_spec.rb58
2 files changed, 55 insertions, 27 deletions
diff --git a/spec/services/projects/group_links/create_service_spec.rb b/spec/services/projects/group_links/create_service_spec.rb
index c249a51fc56..9bc780fe177 100644
--- a/spec/services/projects/group_links/create_service_spec.rb
+++ b/spec/services/projects/group_links/create_service_spec.rb
@@ -38,7 +38,7 @@ RSpec.describe Projects::GroupLinks::CreateService, '#execute' do
expect { subject.execute(create(:group)) }.not_to change { project.project_group_links.count }
end
- context 'with specialized_project_authorization_workers' do
+ context 'with specialized project_authorization workers' do
let_it_be(:other_user) { create(:user) }
before do
@@ -54,7 +54,7 @@ RSpec.describe Projects::GroupLinks::CreateService, '#execute' do
.with(project.id, group.id, group_access)
.and_call_original
)
- expect(AuthorizedProjectUpdate::UserRefreshWithLowUrgencyWorker).to(
+ expect(AuthorizedProjectUpdate::UserRefreshFromReplicaWorker).to(
receive(:bulk_perform_in)
.with(1.hour,
array_including([user.id], [other_user.id]),
@@ -64,25 +64,5 @@ RSpec.describe Projects::GroupLinks::CreateService, '#execute' do
subject.execute(group)
end
-
- context 'when feature is disabled' do
- before do
- stub_feature_flags(specialized_project_authorization_project_share_worker: false)
- end
-
- it 'uses AuthorizedProjectsWorker' do
- expect(AuthorizedProjectsWorker).to(
- receive(:bulk_perform_async).with(array_including([user.id], [other_user.id])).and_call_original
- )
- expect(AuthorizedProjectUpdate::ProjectCreateWorker).not_to(
- receive(:perform_async)
- )
- expect(AuthorizedProjectUpdate::UserRefreshWithLowUrgencyWorker).not_to(
- receive(:bulk_perform_in)
- )
-
- subject.execute(group)
- end
- end
end
end
diff --git a/spec/services/projects/group_links/destroy_service_spec.rb b/spec/services/projects/group_links/destroy_service_spec.rb
index 459b79b2d7d..d60e9a01e54 100644
--- a/spec/services/projects/group_links/destroy_service_spec.rb
+++ b/spec/services/projects/group_links/destroy_service_spec.rb
@@ -14,12 +14,60 @@ RSpec.describe Projects::GroupLinks::DestroyService, '#execute' do
expect { subject.execute(group_link) }.to change { project.project_group_links.count }.from(1).to(0)
end
- it 'updates authorization' do
- group.add_maintainer(user)
+ context 'project authorizations refresh' do
+ before do
+ group.add_maintainer(user)
+ end
+
+ context 'when the feature flag `use_specialized_worker_for_project_auth_recalculation` is enabled' do
+ before do
+ stub_feature_flags(use_specialized_worker_for_project_auth_recalculation: true)
+ end
+
+ it 'calls AuthorizedProjectUpdate::ProjectRecalculateWorker to update project authorizations' do
+ expect(AuthorizedProjectUpdate::ProjectRecalculateWorker)
+ .to receive(:perform_async).with(group_link.project.id)
+
+ subject.execute(group_link)
+ end
+
+ it 'calls AuthorizedProjectUpdate::UserRefreshFromReplicaWorker with a delay to update project authorizations' do
+ expect(AuthorizedProjectUpdate::UserRefreshFromReplicaWorker).to(
+ receive(:bulk_perform_in)
+ .with(1.hour,
+ [[user.id]],
+ batch_delay: 30.seconds, batch_size: 100)
+ )
+
+ subject.execute(group_link)
+ end
- expect { subject.execute(group_link) }.to(
- change { Ability.allowed?(user, :read_project, project) }
- .from(true).to(false))
+ it 'updates project authorizations of users who had access to the project via the group share', :sidekiq_inline do
+ expect { subject.execute(group_link) }.to(
+ change { Ability.allowed?(user, :read_project, project) }
+ .from(true).to(false))
+ end
+ end
+
+ context 'when the feature flag `use_specialized_worker_for_project_auth_recalculation` is disabled' do
+ before do
+ stub_feature_flags(use_specialized_worker_for_project_auth_recalculation: false)
+ end
+
+ it 'calls UserProjectAccessChangedService to update project authorizations' do
+ expect_next_instance_of(UserProjectAccessChangedService, [user.id]) do |service|
+ expect(service).to receive(:execute)
+ end
+
+ subject.execute(group_link)
+ end
+
+ it 'updates project authorizations of users who had access to the project via the group share' do
+ expect { subject.execute(group_link) }.to(
+ change { Ability.allowed?(user, :read_project, project) }
+ .from(true).to(false))
+ end
+ end
end
it 'returns false if group_link is blank' do