Commit f28aeac8 authored by Manoj M J's avatar Manoj M J

Use new worker/service to refresh authorizations of project members

With this change, we will be using a specialized
worker/service to refresh authorizations
whenever a project member
is created/updated/deleted

Changelog: performance
parent dbdbaa51
......@@ -94,7 +94,6 @@ class ProjectMember < Member
override :refresh_member_authorized_projects
def refresh_member_authorized_projects(blocking:)
return super unless Feature.enabled?(:specialized_service_for_project_member_auth_refresh)
return unless user
# rubocop:disable CodeReuse/ServiceClass
......
---
name: specialized_service_for_project_member_auth_refresh
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/67477
rollout_issue_url: https://gitlab.com/gitlab-org/gitlab/-/issues/337730
milestone: '14.2'
type: development
group: group::access
default_enabled: false
......@@ -256,59 +256,5 @@ RSpec.describe ProjectMember do
it_behaves_like 'calls AuthorizedProjectUpdate::UserRefreshFromReplicaWorker with a delay to update project authorizations'
end
context 'when the feature flag `specialized_service_for_project_member_auth_refresh` is disabled' do
before do
stub_feature_flags(specialized_service_for_project_member_auth_refresh: false)
end
shared_examples_for 'calls UserProjectAccessChangedService to recalculate authorizations' do
it 'calls UserProjectAccessChangedService' do
expect_next_instance_of(UserProjectAccessChangedService, user.id) do |service|
expect(service).to receive(:execute)
end
action
end
end
context 'on create' do
let(:action) { project.add_user(user, Gitlab::Access::GUEST) }
it 'changes access level' do
expect { action }.to change { user.can?(:guest_access, project) }.from(false).to(true)
end
it_behaves_like 'calls UserProjectAccessChangedService to recalculate authorizations'
end
context 'on update' do
let(:action) { project.members.find_by(user: user).update!(access_level: Gitlab::Access::DEVELOPER) }
before do
project.add_user(user, Gitlab::Access::GUEST)
end
it 'changes access level' do
expect { action }.to change { user.can?(:developer_access, project) }.from(false).to(true)
end
it_behaves_like 'calls UserProjectAccessChangedService to recalculate authorizations'
end
context 'on destroy' do
let(:action) { project.members.find_by(user: user).destroy! }
before do
project.add_user(user, Gitlab::Access::GUEST)
end
it 'changes access level', :sidekiq_inline do
expect { action }.to change { user.can?(:guest_access, project) }.from(true).to(false)
end
it_behaves_like 'calls UserProjectAccessChangedService to recalculate authorizations'
end
end
end
end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment