Commit 69f584ed authored by Toon Claes's avatar Toon Claes
Browse files

Make namespace owner master of project upon creation

When an admin creates a project in the namespace of a user, that user
automatically gains master access to that project.
parent 025b04f3
......@@ -97,7 +97,8 @@ def after_create_actions
system_hook_service.execute_hooks_for(@project, :create)
unless @project.group || @project.gitlab_project_import?
@project.team << [current_user, :master, current_user]
owners = [current_user, @project.namespace.owner].compact.uniq
@project.add_master(owners, current_user: current_user)
end
@project.group&.refresh_members_authorized_projects
......
---
title: Ensure namespace owner is Master of project upon creation
merge_request: 10910
author:
......@@ -27,6 +27,22 @@
end
end
context "admin creates project with other user's namespace_id" do
it 'sets the correct permissions' do
admin = create(:admin)
opts = {
name: 'GitLab',
namespace_id: user.namespace.id
}
project = create_project(admin, opts)
expect(project).to be_persisted
expect(project.owner).to eq(user)
expect(project.team.masters).to include(user, admin)
expect(project.namespace).to eq(user.namespace)
end
end
context 'group namespace' do
let(:group) do
create(:group).tap do |group|
......
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