Commit a89c590ffef54c9ff4c790b5d91a8afe68b1ee42

Authored by Dmitriy Zaporozhets
1 parent c283fba3

Prevent exceptions for methods like ProjectTeam#developer? if no membership exists

Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
Showing 1 changed file with 4 additions and 4 deletions   Show diff stats
app/models/project_team.rb
... ... @@ -118,19 +118,19 @@ class ProjectTeam
118 118 end
119 119  
120 120 def guest?(user)
121   - find_tm(user.id).access_field == Gitlab::Access::GUEST
  121 + find_tm(user.id).try(:access_field) == Gitlab::Access::GUEST
122 122 end
123 123  
124 124 def reporter?(user)
125   - find_tm(user.id).access_field == Gitlab::Access::REPORTER
  125 + find_tm(user.id).try(:access_field) == Gitlab::Access::REPORTER
126 126 end
127 127  
128 128 def developer?(user)
129   - find_tm(user.id).access_field == Gitlab::Access::DEVELOPER
  129 + find_tm(user.id).try(:access_field) == Gitlab::Access::DEVELOPER
130 130 end
131 131  
132 132 def master?(user)
133   - find_tm(user.id).access_field == Gitlab::Access::MASTER
  133 + find_tm(user.id).try(:access_field) == Gitlab::Access::MASTER
134 134 end
135 135  
136 136 private
... ...