diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-09-20 13:18:24 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-09-20 13:18:24 +0000 |
commit | 0653e08efd039a5905f3fa4f6e9cef9f5d2f799c (patch) | |
tree | 4dcc884cf6d81db44adae4aa99f8ec1233a41f55 /lib/gitlab/seeder.rb | |
parent | 744144d28e3e7fddc117924fef88de5d9674fe4c (diff) | |
download | gitlab-ce-0653e08efd039a5905f3fa4f6e9cef9f5d2f799c.tar.gz |
Add latest changes from gitlab-org/gitlab@14-3-stable-eev14.3.0-rc42
Diffstat (limited to 'lib/gitlab/seeder.rb')
-rw-r--r-- | lib/gitlab/seeder.rb | 36 |
1 files changed, 15 insertions, 21 deletions
diff --git a/lib/gitlab/seeder.rb b/lib/gitlab/seeder.rb index 4158cec9b09..5671fce481f 100644 --- a/lib/gitlab/seeder.rb +++ b/lib/gitlab/seeder.rb @@ -1,17 +1,5 @@ # frozen_string_literal: true -# :nocov: -module DeliverNever - def deliver_later - self - end -end - -module MuteNotifications - def new_note(note) - end -end - module Gitlab class Seeder extend ActionView::Helpers::NumberHelper @@ -82,18 +70,22 @@ module Gitlab Project.include(ProjectSeed) User.include(UserSeed) - mute_notifications - mute_mailer + old_perform_deliveries = ActionMailer::Base.perform_deliveries + ActionMailer::Base.perform_deliveries = false SeedFu.quiet = true without_statement_timeout do - yield + without_new_note_notifications do + yield + end end + puts "\nOK".color(:green) + ensure SeedFu.quiet = false + ActionMailer::Base.perform_deliveries = old_perform_deliveries ActiveRecord::Base.logger = old_logger - puts "\nOK".color(:green) end def self.without_gitaly_timeout @@ -109,12 +101,14 @@ module Gitlab ApplicationSetting.expire end - def self.mute_notifications - NotificationService.prepend(MuteNotifications) - end + def self.without_new_note_notifications + NotificationService.alias_method :original_new_note, :new_note + NotificationService.define_method(:new_note) { |note| } - def self.mute_mailer - ActionMailer::MessageDelivery.prepend(DeliverNever) + yield + ensure + NotificationService.alias_method :new_note, :original_new_note + NotificationService.remove_method :original_new_note end def self.without_statement_timeout |