diff options
author | Douwe Maan <douwe@gitlab.com> | 2016-02-19 07:50:05 +0000 |
---|---|---|
committer | Rémy Coutable <remy@rymai.me> | 2016-02-19 16:29:31 +0100 |
commit | 554d9bf606176f7e7515ad8976dff9ef77acd4ca (patch) | |
tree | 7d979f5942bd9effe1e6b755c7e2d0d367bb9d91 | |
parent | 6eacfa99869df5639d20079ccffb399fe22387ed (diff) | |
download | gitlab-ce-554d9bf606176f7e7515ad8976dff9ef77acd4ca.tar.gz |
Merge branch 'rs-show-owner-label' into 'master'
Allow `ProjectTeam#human_max_access` to return "Owner"
See merge request !2881
-rw-r--r-- | app/models/project_team.rb | 2 | ||||
-rw-r--r-- | spec/models/project_team_spec.rb | 26 |
2 files changed, 19 insertions, 9 deletions
diff --git a/app/models/project_team.rb b/app/models/project_team.rb index 9f380a382cb..9629c7e1bb9 100644 --- a/app/models/project_team.rb +++ b/app/models/project_team.rb @@ -136,7 +136,7 @@ class ProjectTeam end def human_max_access(user_id) - Gitlab::Access.options.key max_member_access(user_id) + Gitlab::Access.options_with_owner.key(max_member_access(user_id)) end # This method assumes project and group members are eager loaded for optimal diff --git a/spec/models/project_team_spec.rb b/spec/models/project_team_spec.rb index 5cd5ae327bf..7b63da005f0 100644 --- a/spec/models/project_team_spec.rb +++ b/spec/models/project_team_spec.rb @@ -68,14 +68,24 @@ describe ProjectTeam, models: true do end describe "#human_max_access" do - it "return master role" do - user = create :user - group = create :group - group.add_users([user.id], GroupMember::MASTER) - project = create(:project, namespace: group) - project.team << [user, :guest] - - expect(project.team.human_max_access(user.id)).to eq("Master") + it 'returns Master role' do + user = create(:user) + group = create(:group) + group.add_master(user) + + project = build_stubbed(:empty_project, namespace: group) + + expect(project.team.human_max_access(user.id)).to eq 'Master' + end + + it 'returns Owner role' do + user = create(:user) + group = create(:group) + group.add_owner(user) + + project = build_stubbed(:empty_project, namespace: group) + + expect(project.team.human_max_access(user.id)).to eq 'Owner' end end end |