diff options
Diffstat (limited to 'spec/services/users/refresh_authorized_projects_service_spec.rb')
-rw-r--r-- | spec/services/users/refresh_authorized_projects_service_spec.rb | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/spec/services/users/refresh_authorized_projects_service_spec.rb b/spec/services/users/refresh_authorized_projects_service_spec.rb index e45cb05a6c5..9404668e3c5 100644 --- a/spec/services/users/refresh_authorized_projects_service_spec.rb +++ b/spec/services/users/refresh_authorized_projects_service_spec.rb @@ -76,6 +76,26 @@ RSpec.describe Users::RefreshAuthorizedProjectsService do service.execute_without_lease end + it 'removes duplicate entries' do + [Gitlab::Access::MAINTAINER, Gitlab::Access::REPORTER].each do |access_level| + user.project_authorizations.create!(project: project, access_level: access_level) + end + + expect(service).to( + receive(:update_authorizations) + .with([project.id], [[user.id, project.id, Gitlab::Access::MAINTAINER]]) + .and_call_original) + + service.execute_without_lease + + expect(user.project_authorizations.count).to eq(1) + project_authorization = ProjectAuthorization.where( + project_id: project.id, + user_id: user.id, + access_level: Gitlab::Access::MAINTAINER) + expect(project_authorization).to exist + end + it 'sets the access level of a project to the highest available level' do user.project_authorizations.delete_all |