diff options
author | Robert Speicher <rspeicher@gmail.com> | 2016-11-18 15:52:39 +0300 |
---|---|---|
committer | Robert Speicher <rspeicher@gmail.com> | 2016-11-18 15:55:04 +0300 |
commit | eef360912320ecfcb427684edf35672b643a87c0 (patch) | |
tree | de26c28e81a3fa72d0427cc19079205cca00d6c5 /app | |
parent | 688ff26df3f288e5cd50096a01014188a5e4011b (diff) |
Add shortcuts for adding users to a project team with a specific role
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')
-rw-r--r-- | app/models/project.rb | 1 | ||||
-rw-r--r-- | app/models/project_team.rb | 16 |
2 files changed, 17 insertions, 0 deletions
diff --git a/app/models/project.rb b/app/models/project.rb index f9bcc547c36..facaddb3aa4 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -158,6 +158,7 @@ class Project < ActiveRecord::Base delegate :name, to: :owner, allow_nil: true, prefix: true delegate :members, to: :team, prefix: true delegate :add_user, to: :team + delegate :add_guest, :add_reporter, :add_developer, :add_master, to: :team # Validations validates :creator, presence: true, on: :create 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) |