diff options
author | Douglas Barbosa Alexandre <dbalexandre@gmail.com> | 2016-04-08 17:35:21 -0300 |
---|---|---|
committer | Douglas Barbosa Alexandre <dbalexandre@gmail.com> | 2016-04-08 18:46:45 -0300 |
commit | 635b65d1206293d0b92322df18d458447ee73d5a (patch) | |
tree | 22f0f1a9ed9ce8e9c7b6e440f87c6800167cbaeb | |
parent | ee497599cc69b126cc2e4a929f1799d3d3eb989d (diff) | |
download | gitlab-ce-635b65d1206293d0b92322df18d458447ee73d5a.tar.gz |
Add method to return the user notification setting for a group, or a project
-rw-r--r-- | app/controllers/projects_controller.rb | 2 | ||||
-rw-r--r-- | app/models/user.rb | 4 |
2 files changed, 5 insertions, 1 deletions
diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb index 39f436f6f4e..3768efe142a 100644 --- a/app/controllers/projects_controller.rb +++ b/app/controllers/projects_controller.rb @@ -105,7 +105,7 @@ class ProjectsController < Projects::ApplicationController @membership = @project.team.find_member(current_user.id) if @membership - @notification_setting = current_user.notification_settings.find_or_initialize_by(source: @project) + @notification_setting = current_user.notification_settings_for(@project) end end diff --git a/app/models/user.rb b/app/models/user.rb index f68379fd050..031315debd7 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -831,6 +831,10 @@ class User < ActiveRecord::Base end end + def notification_settings_for(source) + notification_settings.find_or_initialize_by(source: source) + end + private def projects_union |