diff options
Diffstat (limited to 'app/models/user.rb')
-rw-r--r-- | app/models/user.rb | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/app/models/user.rb b/app/models/user.rb index d2da83ab4b3..7afbfbf112a 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -797,9 +797,12 @@ class User < ActiveRecord::Base # Lazy load global notification setting # Initializes User setting with Participating level if setting not persisted def global_notification_setting - setting = notification_settings.find_or_initialize_by(source: nil) - setting.level = NotificationSetting.levels[DEFAULT_NOTIFICATION_LEVEL] unless setting.persisted? - setting + return @global_notification_setting if defined?(@global_notification_setting) + + @global_notification_setting = notification_settings.find_or_initialize_by(source: nil) + @global_notification_setting.update_attributes(level: NotificationSetting.levels[DEFAULT_NOTIFICATION_LEVEL]) unless @global_notification_setting.persisted? + + @global_notification_setting end def assigned_open_merge_request_count(force: false) |