Commit 176fa21c authored by Lin Jen-Shin's avatar Lin Jen-Shin

raise UnknownIncomingEmail when there's no mail_key:

So that we don't have to pretend that CreateNoteHandler
could handle a nil mail_key. Also, since NilClass#=~ would
just return nil for any regular expression, we could just
match it without checking nilness.

Feedback:
https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/3363#note_12566407
parent 0671db52
...@@ -6,8 +6,7 @@ module Gitlab ...@@ -6,8 +6,7 @@ module Gitlab
module Handler module Handler
class CreateNoteHandler < BaseHandler class CreateNoteHandler < BaseHandler
def can_handle? def can_handle?
# We want to raise SentNotificationNotFoundError for missing key mail_key =~ /\A\w+\z/
!!(mail_key.nil? || mail_key =~ /\A\w+\z/)
end end
def execute def execute
......
...@@ -20,8 +20,8 @@ describe Gitlab::Email::Handler::CreateNoteHandler, lib: true do ...@@ -20,8 +20,8 @@ describe Gitlab::Email::Handler::CreateNoteHandler, lib: true do
context "when the recipient address doesn't include a mail key" do context "when the recipient address doesn't include a mail key" do
let(:email_raw) { fixture_file('emails/valid_reply.eml').gsub(mail_key, "") } let(:email_raw) { fixture_file('emails/valid_reply.eml').gsub(mail_key, "") }
it "raises a SentNotificationNotFoundError" do it "raises a UnknownIncomingEmail" do
expect { receiver.execute }.to raise_error(Gitlab::Email::SentNotificationNotFoundError) expect { receiver.execute }.to raise_error(Gitlab::Email::UnknownIncomingEmail)
end end
end end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment