Merge branch 'access_level_badge_bug' into 'master'

Fix: Wrong access level badge on MR comments

https://gitlab.com/gitlab-org/gitlab-ce/issues/2654

See merge request !1501
This commit is contained in:
Dmitriy Zaporozhets 2015-10-02 14:39:58 +00:00
commit 0e7b96bf48
4 changed files with 20 additions and 3 deletions

View file

@ -26,6 +26,7 @@ v 8.1.0 (unreleased)
- Show additions/deletions stats on merge request diff
- Remove footer text in emails (Zeger-Jan van de Weg)
- Ensure code blocks are properly highlighted after a note is updated
- Fix wrong access level badge on MR comments
v 8.0.3
- Fix URL shown in Slack notifications

View file

@ -135,6 +135,10 @@ class ProjectTeam
!!find_member(user_id)
end
def human_max_access(user_id)
Gitlab::Access.options.key max_member_access(user_id)
end
def max_member_access(user_id)
access = []
access << project.project_members.find_by(user_id: user_id).try(:access_field)

View file

@ -14,10 +14,10 @@
= icon('trash-o')
- unless note.system
- member = note.project.team.find_member(note.author.id)
- if member
- access = note.project.team.human_max_access(note.author.id)
- if access
%span.note-role.label
= member.human_access
= access
= link_to_member(note.project, note.author, avatar: false)

View file

@ -66,4 +66,16 @@ describe ProjectTeam do
it { expect(project.team.member?(guest)).to be_truthy }
end
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")
end
end
end