summaryrefslogtreecommitdiff
path: root/spec/services/members
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2022-10-31 03:10:36 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2022-10-31 03:10:36 +0000
commit853c0c530b624a2f94ce85acbbdffc70510bdba3 (patch)
tree6f007358e587963e04e64f733e5f00a3dc08c524 /spec/services/members
parentbef48349bb06706c012d7524b37d2a9f7563d139 (diff)
downloadgitlab-ce-853c0c530b624a2f94ce85acbbdffc70510bdba3.tar.gz
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/services/members')
-rw-r--r--spec/services/members/update_service_spec.rb60
1 files changed, 55 insertions, 5 deletions
diff --git a/spec/services/members/update_service_spec.rb b/spec/services/members/update_service_spec.rb
index f919d6d1516..eca40860bda 100644
--- a/spec/services/members/update_service_spec.rb
+++ b/spec/services/members/update_service_spec.rb
@@ -14,6 +14,11 @@ RSpec.describe Members::UpdateService do
{ access_level: access_level }
end
+ before do
+ project.add_developer(member_user)
+ group.add_developer(member_user)
+ end
+
subject { described_class.new(current_user, params).execute(member, permission: permission) }
shared_examples 'a service raising Gitlab::Access::AccessDeniedError' do
@@ -83,11 +88,6 @@ RSpec.describe Members::UpdateService do
end
end
- before do
- project.add_developer(member_user)
- group.add_developer(member_user)
- end
-
context 'when current user cannot update the given member' do
it_behaves_like 'a service raising Gitlab::Access::AccessDeniedError' do
let(:source) { project }
@@ -183,4 +183,54 @@ RSpec.describe Members::UpdateService do
end
end
end
+
+ context 'authorization updates' do
+ let_it_be(:user) { create(:user) }
+
+ shared_examples 'manages authorization updates' do
+ context 'access level changes' do
+ let(:params) do
+ { access_level: Gitlab::Access::MAINTAINER }
+ end
+
+ it 'authorization update callback is triggered' do
+ expect(member).to receive(:refresh_member_authorized_projects).once
+
+ described_class.new(current_user, params).execute(member, permission: permission)
+ end
+ end
+
+ context 'no attribute changes' do
+ let(:params) do
+ { access_level: Gitlab::Access::DEVELOPER }
+ end
+
+ it 'authorization update callback is not triggered' do
+ expect(member).not_to receive(:refresh_member_authorized_projects)
+
+ described_class.new(current_user, params).execute(member, permission: permission)
+ end
+ end
+ end
+
+ context 'group member' do
+ let(:source) { group }
+
+ before do
+ group.add_owner(current_user)
+ end
+
+ include_examples 'manages authorization updates'
+ end
+
+ context 'project member' do
+ let(:source) { project }
+
+ before do
+ project.add_maintainer(current_user)
+ end
+
+ include_examples 'manages authorization updates'
+ end
+ end
end