diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-12-20 16:37:47 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-12-20 16:37:47 +0300 |
commit | aee0a117a889461ce8ced6fcf73207fe017f1d99 (patch) | |
tree | 891d9ef189227a8445d83f35c1b0fc99573f4380 /spec/services/users | |
parent | 8d46af3258650d305f53b819eabf7ab18d22f59e (diff) |
Add latest changes from gitlab-org/gitlab@14-6-stable-eev14.6.0-rc42
Diffstat (limited to 'spec/services/users')
-rw-r--r-- | spec/services/users/dismiss_callout_service_spec.rb (renamed from spec/services/users/dismiss_user_callout_service_spec.rb) | 6 | ||||
-rw-r--r-- | spec/services/users/refresh_authorized_projects_service_spec.rb | 39 |
2 files changed, 35 insertions, 10 deletions
diff --git a/spec/services/users/dismiss_user_callout_service_spec.rb b/spec/services/users/dismiss_callout_service_spec.rb index 6bf9961eb74..6ba9f180444 100644 --- a/spec/services/users/dismiss_user_callout_service_spec.rb +++ b/spec/services/users/dismiss_callout_service_spec.rb @@ -2,12 +2,12 @@ require 'spec_helper' -RSpec.describe Users::DismissUserCalloutService do +RSpec.describe Users::DismissCalloutService do describe '#execute' do let_it_be(:user) { create(:user) } let(:params) { { feature_name: feature_name } } - let(:feature_name) { UserCallout.feature_names.each_key.first } + let(:feature_name) { Users::Callout.feature_names.each_key.first } subject(:execute) do described_class.new( @@ -15,6 +15,6 @@ RSpec.describe Users::DismissUserCalloutService do ).execute end - it_behaves_like 'dismissing user callout', UserCallout + it_behaves_like 'dismissing user callout', Users::Callout end end diff --git a/spec/services/users/refresh_authorized_projects_service_spec.rb b/spec/services/users/refresh_authorized_projects_service_spec.rb index a8ad0d02f60..aa4df93a241 100644 --- a/spec/services/users/refresh_authorized_projects_service_spec.rb +++ b/spec/services/users/refresh_authorized_projects_service_spec.rb @@ -67,11 +67,17 @@ RSpec.describe Users::RefreshAuthorizedProjectsService do it 'updates the authorized projects of the user' do project2 = create(:project) - to_remove = user.project_authorizations + project_authorization = user.project_authorizations .create!(project: project2, access_level: Gitlab::Access::MAINTAINER) + to_be_removed = [project_authorization.project_id] + + to_be_added = [ + { user_id: user.id, project_id: project.id, access_level: Gitlab::Access::MAINTAINER } + ] + expect(service).to receive(:update_authorizations) - .with([to_remove.project_id], [[user.id, project.id, Gitlab::Access::MAINTAINER]]) + .with(to_be_removed, to_be_added) service.execute_without_lease end @@ -81,9 +87,14 @@ RSpec.describe Users::RefreshAuthorizedProjectsService do user.project_authorizations.create!(project: project, access_level: access_level) end + to_be_removed = [project.id] + + to_be_added = [ + { user_id: user.id, project_id: project.id, access_level: Gitlab::Access::MAINTAINER } + ] expect(service).to( receive(:update_authorizations) - .with([project.id], [[user.id, project.id, Gitlab::Access::MAINTAINER]]) + .with(to_be_removed, to_be_added) .and_call_original) service.execute_without_lease @@ -99,11 +110,17 @@ RSpec.describe Users::RefreshAuthorizedProjectsService do it 'sets the access level of a project to the highest available level' do user.project_authorizations.delete_all - to_remove = user.project_authorizations + project_authorization = user.project_authorizations .create!(project: project, access_level: Gitlab::Access::DEVELOPER) + to_be_removed = [project_authorization.project_id] + + to_be_added = [ + { user_id: user.id, project_id: project.id, access_level: Gitlab::Access::MAINTAINER } + ] + expect(service).to receive(:update_authorizations) - .with([to_remove.project_id], [[user.id, project.id, Gitlab::Access::MAINTAINER]]) + .with(to_be_removed, to_be_added) service.execute_without_lease end @@ -134,7 +151,11 @@ RSpec.describe Users::RefreshAuthorizedProjectsService do it 'inserts authorizations that should be added' do user.project_authorizations.delete_all - service.update_authorizations([], [[user.id, project.id, Gitlab::Access::MAINTAINER]]) + to_be_added = [ + { user_id: user.id, project_id: project.id, access_level: Gitlab::Access::MAINTAINER } + ] + + service.update_authorizations([], to_be_added) authorizations = user.project_authorizations @@ -160,7 +181,11 @@ RSpec.describe Users::RefreshAuthorizedProjectsService do 'authorized_projects_refresh.rows_added_slice': [[user.id, project.id, Gitlab::Access::MAINTAINER]]) ) - service.update_authorizations([], [[user.id, project.id, Gitlab::Access::MAINTAINER]]) + to_be_added = [ + { user_id: user.id, project_id: project.id, access_level: Gitlab::Access::MAINTAINER } + ] + + service.update_authorizations([], to_be_added) end end end |