summaryrefslogtreecommitdiff
path: root/spec/services/users
diff options
context:
space:
mode:
Diffstat (limited to 'spec/services/users')
-rw-r--r--spec/services/users/create_service_spec.rb1
-rw-r--r--spec/services/users/refresh_authorized_projects_service_spec.rb20
2 files changed, 21 insertions, 0 deletions
diff --git a/spec/services/users/create_service_spec.rb b/spec/services/users/create_service_spec.rb
index 69d2d6ca9ff..9040966215c 100644
--- a/spec/services/users/create_service_spec.rb
+++ b/spec/services/users/create_service_spec.rb
@@ -154,6 +154,7 @@ RSpec.describe Users::CreateService do
let(:params) do
{ name: 'John Doe', username: 'jduser', email: 'jd@example.com', password: 'mydummypass', skip_confirmation: true }
end
+
let(:service) { described_class.new(nil, params) }
it 'persists the given attributes' do
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