Extract EE-specific lines from Gitlab::Email::Handler

This commit is contained in:
Sean McGivern 2018-08-23 10:04:41 +01:00
parent a3382bab11
commit 74616ece28
2 changed files with 14 additions and 8 deletions

View file

@ -6,15 +6,21 @@ require 'gitlab/email/handler/unsubscribe_handler'
module Gitlab
module Email
module Handler
HANDLERS = [
UnsubscribeHandler,
CreateNoteHandler,
CreateMergeRequestHandler,
CreateIssueHandler
].freeze
def self.handlers
@handlers ||= load_handlers
end
def self.load_handlers
[
UnsubscribeHandler,
CreateNoteHandler,
CreateMergeRequestHandler,
CreateIssueHandler
]
end
def self.for(mail, mail_key)
HANDLERS.find do |klass|
handlers.find do |klass|
handler = klass.new(mail, mail_key)
break handler if handler.can_handle?
end

View file

@ -40,7 +40,7 @@ describe Gitlab::Email::Handler do
end
def ce_handlers
@ce_handlers ||= Gitlab::Email::Handler::HANDLERS.reject do |handler|
@ce_handlers ||= Gitlab::Email::Handler.handlers.reject do |handler|
handler.name.start_with?('Gitlab::Email::Handler::EE::')
end
end