diff options
author | Douwe Maan <douwe@gitlab.com> | 2015-04-14 12:33:27 +0200 |
---|---|---|
committer | Douwe Maan <douwe@gitlab.com> | 2015-04-14 12:41:19 +0200 |
commit | 0013ea5130494326f37fb1d6988a369fa2c91d22 (patch) | |
tree | 78f8e3313ddb3d25be139673e0e0b08b1f5366e3 /app/models/members | |
parent | a8b462bbfe3647574e17c483aad27281c2adc5f2 (diff) | |
download | gitlab-ce-0013ea5130494326f37fb1d6988a369fa2c91d22.tar.gz |
Remove duplication between Group and ProjectMember.
Diffstat (limited to 'app/models/members')
-rw-r--r-- | app/models/members/project_member.rb | 19 |
1 files changed, 2 insertions, 17 deletions
diff --git a/app/models/members/project_member.rb b/app/models/members/project_member.rb index 8af7499dd82..ce704a60d63 100644 --- a/app/models/members/project_member.rb +++ b/app/models/members/project_member.rb @@ -60,29 +60,14 @@ class ProjectMember < Member raise "Non valid access" end - users = user_ids.map do |user_id| - (user_id if user_id.is_a?(User)) || - User.find_by(id: user_id) || - User.find_by(email: user_id) || - user_id - end + users = user_ids.map { |user_id| Member.user_for_id(user_id) } ProjectMember.transaction do project_ids.each do |project_id| project = Project.find(project_id) users.each do |user| - if user.is_a?(User) - member = project.project_members.find_or_initialize_by(user_id: user.id) - else - member = project.project_members.build - member.invite_email = user - end - - member.created_by ||= current_user - member.access_level = access_level - - member.save + Member.add_user(project.project_members, user, access_level, current_user) end end end |