Ensure Owners are included in the scope for authorized_projects
Prior, when providing a `min_access_level` parameter to this method, we called `Gitlab::Access.values` instead of `all_values`, mistakenly omitting the `OWNER` level. Fixes https://gitlab.com/gitlab-org/gitlab-ce/issues/19878
This commit is contained in:
parent
1d7ac1641e
commit
17bac49154
|
@ -854,7 +854,7 @@ class User < ActiveRecord::Base
|
|||
groups.joins(:shared_projects).select(:project_id)]
|
||||
|
||||
if min_access_level
|
||||
scope = { access_level: Gitlab::Access.values.select { |access| access >= min_access_level } }
|
||||
scope = { access_level: Gitlab::Access.all_values.select { |access| access >= min_access_level } }
|
||||
relations = [relations.shift] + relations.map { |relation| relation.where(members: scope) }
|
||||
end
|
||||
|
||||
|
|
|
@ -887,16 +887,25 @@ describe User, models: true do
|
|||
end
|
||||
|
||||
describe '#authorized_projects' do
|
||||
let!(:user) { create(:user) }
|
||||
let!(:private_project) { create(:project, :private) }
|
||||
context 'with a minimum access level' do
|
||||
it 'includes projects for which the user is an owner' do
|
||||
user = create(:user)
|
||||
project = create(:empty_project, :private, namespace: user.namespace)
|
||||
|
||||
before do
|
||||
private_project.team << [user, Gitlab::Access::MASTER]
|
||||
expect(user.authorized_projects(Gitlab::Access::REPORTER))
|
||||
.to contain_exactly(project)
|
||||
end
|
||||
|
||||
subject { user.authorized_projects }
|
||||
it 'includes projects for which the user is a master' do
|
||||
user = create(:user)
|
||||
project = create(:empty_project, :private)
|
||||
|
||||
it { is_expected.to eq([private_project]) }
|
||||
project.team << [user, Gitlab::Access::MASTER]
|
||||
|
||||
expect(user.authorized_projects(Gitlab::Access::REPORTER))
|
||||
.to contain_exactly(project)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe '#ci_authorized_runners' do
|
||||
|
|
Loading…
Reference in New Issue