summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorValery Sizov <vsv2711@gmail.com>2015-10-02 15:10:33 +0300
committerValery Sizov <vsv2711@gmail.com>2015-10-02 15:11:17 +0300
commit97e6c9b42ca65be14f64f1528821922b2b0bd04a (patch)
tree2b48a6c6f58cc3cb91258f194ad2d5758c5d4477
parentc867c225095319684ad6ff396e4194bb1b5920d5 (diff)
downloadgitlab-ce-access_level_badge_bug.tar.gz
Wrong access level badge on MR commentsaccess_level_badge_bug
-rw-r--r--CHANGELOG1
-rw-r--r--app/models/project_team.rb4
-rw-r--r--app/views/projects/notes/_note.html.haml6
-rw-r--r--spec/models/project_team_spec.rb12
4 files changed, 20 insertions, 3 deletions
diff --git a/CHANGELOG b/CHANGELOG
index a8b43dd4608..d0bc80daafe 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -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
diff --git a/app/models/project_team.rb b/app/models/project_team.rb
index 56e49af2324..f602a965364 100644
--- a/app/models/project_team.rb
+++ b/app/models/project_team.rb
@@ -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)
diff --git a/app/views/projects/notes/_note.html.haml b/app/views/projects/notes/_note.html.haml
index cf5d5d6d8ba..1638ad6891a 100644
--- a/app/views/projects/notes/_note.html.haml
+++ b/app/views/projects/notes/_note.html.haml
@@ -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)
diff --git a/spec/models/project_team_spec.rb b/spec/models/project_team_spec.rb
index cc1138490a0..26e8fdae472 100644
--- a/spec/models/project_team_spec.rb
+++ b/spec/models/project_team_spec.rb
@@ -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