Commit 200ebab1 authored by Sean McGivern's avatar Sean McGivern

Merge branch '55098-ui-bug-adding-group-members-with-lower-permissions' into 'master'

Resolve "UI bug adding group members with lower permissions"

Closes #55098

See merge request gitlab-org/gitlab-ce!24820
parents 34908dd2 c75687b5
...@@ -19,9 +19,19 @@ module Members ...@@ -19,9 +19,19 @@ module Members
current_user: current_user current_user: current_user
) )
members.each { |member| after_execute(member: member) } errors = []
success members.each do |member|
if member.errors.any?
errors << "#{member.user.username}: #{member.errors.full_messages.to_sentence}"
else
after_execute(member: member)
end
end
return success unless errors.any?
error(errors.to_sentence)
end end
private private
......
---
title: Resolve UI bug adding group members with lower permissions
merge_request: 24820
author:
type: fixed
...@@ -36,4 +36,13 @@ describe Members::CreateService do ...@@ -36,4 +36,13 @@ describe Members::CreateService do
expect(result[:message]).to be_present expect(result[:message]).to be_present
expect(project.users).not_to include project_user expect(project.users).not_to include project_user
end end
it 'does not add an invalid member' do
params = { user_ids: project_user.id.to_s, access_level: -1 }
result = described_class.new(user, params).execute(project)
expect(result[:status]).to eq(:error)
expect(result[:message]).to include(project_user.username)
expect(project.users).not_to include project_user
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