diff options
author | Wei-Meng Lee <wlee@gitlab.com> | 2019-05-13 15:52:57 -0500 |
---|---|---|
committer | Wei-Meng Lee <wlee@gitlab.com> | 2019-05-31 20:49:27 +0800 |
commit | ddd6f804576e1e9d69db85242a8dbc687cdb35db (patch) | |
tree | 5f3ecfbb3fc6d57f9a75358d2692a6de9ebfe09a | |
parent | f72383066d9758988706e697c26ba35efe90c564 (diff) | |
download | gitlab-ce-ddd6f804576e1e9d69db85242a8dbc687cdb35db.tar.gz |
Move method into group
-rw-r--r-- | app/mailers/notify.rb | 2 | ||||
-rw-r--r-- | app/models/group.rb | 4 |
2 files changed, 5 insertions, 1 deletions
diff --git a/app/mailers/notify.rb b/app/mailers/notify.rb index f78be3882d6..cc27ba0c5cc 100644 --- a/app/mailers/notify.rb +++ b/app/mailers/notify.rb @@ -82,7 +82,7 @@ class Notify < BaseMailer group_notification_email = nil if notification_group - notification_settings = notification_group.notification_settings(hierarchy_order: :asc).where(user: @current_user) # rubocop: disable CodeReuse/ActiveRecord + notification_settings = notification_group.notification_settings_for(@current_user, hierarchy_order: :asc) group_notification_email = notification_settings.find { |n| n.notification_email.present? }&.notification_email end diff --git a/app/models/group.rb b/app/models/group.rb index 25d246f64e7..cdb4e6e87f6 100644 --- a/app/models/group.rb +++ b/app/models/group.rb @@ -138,6 +138,10 @@ class Group < Namespace .order("ordered_groups.depth #{hierarchy_order}") end + def notification_settings_for(user, hierarchy_order: nil) + notification_settings(hierarchy_order: hierarchy_order).where(user: user) + end + def to_reference(_from = nil, full: nil) "#{self.class.reference_prefix}#{full_path}" end |