summaryrefslogtreecommitdiff
path: root/app/models/notification_setting.rb
diff options
context:
space:
mode:
Diffstat (limited to 'app/models/notification_setting.rb')
-rw-r--r--app/models/notification_setting.rb9
1 files changed, 8 insertions, 1 deletions
diff --git a/app/models/notification_setting.rb b/app/models/notification_setting.rb
index d41fc7073c6..121b598b8f3 100644
--- a/app/models/notification_setting.rb
+++ b/app/models/notification_setting.rb
@@ -5,6 +5,7 @@ class NotificationSetting < ActiveRecord::Base
belongs_to :user
belongs_to :source, polymorphic: true
+ belongs_to :project, foreign_key: 'source_id'
validates :user, presence: true
validates :level, presence: true
@@ -13,7 +14,13 @@ class NotificationSetting < ActiveRecord::Base
allow_nil: true }
scope :for_groups, -> { where(source_type: 'Namespace') }
- scope :for_projects, -> { where(source_type: 'Project') }
+
+ # Exclude projects not included by the Project model's default scope (those that are
+ # pending delete).
+ #
+ scope :for_projects, -> do
+ includes(:project).references(:projects).where(source_type: 'Project').where.not(projects: { id: nil })
+ end
EMAIL_EVENTS = [
:new_note,