Commit 4d84259d authored by Robert Speicher's avatar Robert Speicher

Merge branch 'fix-project-creation' into 'master'

Creator should be added as a master of the project on creation

Fixes #4222 

This also enable a project creator to add themselves as a master of the
project for existing repositories that were created in the meanwhile
that they don't appear as members.

See merge request !2520
parents 3a6fac4a 096485ef
......@@ -91,7 +91,7 @@ class Member < ActiveRecord::Base
member.invite_email = user
end
if can_update_member?(current_user, member)
if can_update_member?(current_user, member) || project_creator?(member, access_level)
member.created_by ||= current_user
member.access_level = access_level
......@@ -107,6 +107,11 @@ class Member < ActiveRecord::Base
current_user.can?(:update_group_member, member) ||
current_user.can?(:update_project_member, member)
end
def project_creator?(member, access_level)
member.new_record? && member.owner? &&
access_level.to_i == ProjectMember::MASTER
end
end
def invite?
......
......@@ -95,7 +95,7 @@ module Projects
system_hook_service.execute_hooks_for(@project, :create)
unless @project.group
@project.team << [current_user, :master]
@project.team << [current_user, :master, current_user]
end
@project.import_start if @project.import?
......
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