summaryrefslogtreecommitdiff
path: root/app/models/project_team.rb
diff options
context:
space:
mode:
authorRobert Speicher <rspeicher@gmail.com>2016-11-18 14:52:39 +0200
committerRobert Speicher <rspeicher@gmail.com>2016-11-18 14:55:04 +0200
commiteef360912320ecfcb427684edf35672b643a87c0 (patch)
treede26c28e81a3fa72d0427cc19079205cca00d6c5 /app/models/project_team.rb
parent688ff26df3f288e5cd50096a01014188a5e4011b (diff)
downloadgitlab-ce-eef360912320ecfcb427684edf35672b643a87c0.tar.gz
Add shortcuts for adding users to a project team with a specific rolers-project-team-helpers
This also updates _some_ specs to use these new methods, just to serve as an example for others going forward, but by no means is this exhaustive. Original implementations at !5992 and !6012. Closes https://gitlab.com/gitlab-org/gitlab-ce/issues/20944
Diffstat (limited to 'app/models/project_team.rb')
-rw-r--r--app/models/project_team.rb16
1 files changed, 16 insertions, 0 deletions
diff --git a/app/models/project_team.rb b/app/models/project_team.rb
index a6e911df9bd..65549d8cd08 100644
--- a/app/models/project_team.rb
+++ b/app/models/project_team.rb
@@ -21,6 +21,22 @@ class ProjectTeam
end
end
+ def add_guest(user, current_user: nil)
+ self << [user, :guest, current_user]
+ end
+
+ def add_reporter(user, current_user: nil)
+ self << [user, :reporter, current_user]
+ end
+
+ def add_developer(user, current_user: nil)
+ self << [user, :developer, current_user]
+ end
+
+ def add_master(user, current_user: nil)
+ self << [user, :master, current_user]
+ end
+
def find_member(user_id)
member = project.members.find_by(user_id: user_id)