diff options
author | Robert Speicher <robert@gitlab.com> | 2016-01-21 02:03:59 +0300 |
---|---|---|
committer | Robert Speicher <rspeicher@gmail.com> | 2016-01-21 02:24:26 +0300 |
commit | 0762d07e02cec086e76b7a2b439bc1a758982530 (patch) | |
tree | eccc648a4f5ad959c73b24faeca3910d130d35e2 /app | |
parent | 8366dbdacf8549e42b8c83f0f43713ac56b7839f (diff) |
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
Diffstat (limited to 'app')
-rw-r--r-- | app/models/member.rb | 7 | ||||
-rw-r--r-- | app/services/projects/create_service.rb | 2 |
2 files changed, 7 insertions, 2 deletions
diff --git a/app/models/member.rb b/app/models/member.rb index 28aee2e3799..34efcd0088d 100644 --- a/app/models/member.rb +++ b/app/models/member.rb @@ -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? diff --git a/app/services/projects/create_service.rb b/app/services/projects/create_service.rb index c94d7ab710f..a6820183bee 100644 --- a/app/services/projects/create_service.rb +++ b/app/services/projects/create_service.rb @@ -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? |