Commit a29d56cf authored by Douglas Barbosa Alexandre's avatar Douglas Barbosa Alexandre

Merge branch 'sh-fix-issue-9591' into 'master'

Fix bug where users could not be added in protected branch rules

Closes #9591

See merge request gitlab-org/gitlab-ee!9474
parents 78e60903 7fc3d888
...@@ -96,7 +96,7 @@ module EE ...@@ -96,7 +96,7 @@ module EE
def validate_user_membership def validate_user_membership
return unless user return unless user
unless project.members.where(user: user).exists? unless project.team.member?(user)
self.errors.add(:user, 'is not a member of the project') self.errors.add(:user, 'is not a member of the project')
end end
end end
......
---
title: Fix bug where users could not be added in protected branch rules
merge_request: 9474
author:
type: fixed
...@@ -77,6 +77,15 @@ describe EE::ProtectedRefAccess do ...@@ -77,6 +77,15 @@ describe EE::ProtectedRefAccess do
expect(access_level.errors.count).to eq 1 expect(access_level.errors.count).to eq 1
expect(access_level.errors[:user].first).to eq 'is not a member of the project' expect(access_level.errors[:user].first).to eq 'is not a member of the project'
end end
it 'allows users with access through group' do
new_user = create(:user)
group.add_developer(new_user)
access_level.user = new_user
expect(access_level).to be_valid
end
end end
it 'requires access_level if no user or group is specified' do it 'requires access_level if no user or group is specified' do
......
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