summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLin Jen-Shin <godfat@godfat.org>2016-06-20 19:15:54 +0800
committerLin Jen-Shin <godfat@godfat.org>2016-06-20 19:15:54 +0800
commit176fa21cb75f404b401e021f0cdcc6a138c207eb (patch)
tree2cfd8750023078ee6036eed4ffc31b2482fe5fc4
parent0671db52a8152ad6d0c4104fa5fc437b9fd6c69d (diff)
downloadgitlab-ce-176fa21cb75f404b401e021f0cdcc6a138c207eb.tar.gz
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
-rw-r--r--lib/gitlab/email/handler/create_note_handler.rb3
-rw-r--r--spec/lib/gitlab/email/handler/create_note_handler_spec.rb4
2 files changed, 3 insertions, 4 deletions
diff --git a/lib/gitlab/email/handler/create_note_handler.rb b/lib/gitlab/email/handler/create_note_handler.rb
index 69646651223..06dae31cc27 100644
--- a/lib/gitlab/email/handler/create_note_handler.rb
+++ b/lib/gitlab/email/handler/create_note_handler.rb
@@ -6,8 +6,7 @@ module Gitlab
module Handler
class CreateNoteHandler < BaseHandler
def can_handle?
- # We want to raise SentNotificationNotFoundError for missing key
- !!(mail_key.nil? || mail_key =~ /\A\w+\z/)
+ mail_key =~ /\A\w+\z/
end
def execute
diff --git a/spec/lib/gitlab/email/handler/create_note_handler_spec.rb b/spec/lib/gitlab/email/handler/create_note_handler_spec.rb
index 9b7fb6a1a4b..a2119b0dadf 100644
--- a/spec/lib/gitlab/email/handler/create_note_handler_spec.rb
+++ b/spec/lib/gitlab/email/handler/create_note_handler_spec.rb
@@ -20,8 +20,8 @@ describe Gitlab::Email::Handler::CreateNoteHandler, lib: true 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, "") }
- it "raises a SentNotificationNotFoundError" do
- expect { receiver.execute }.to raise_error(Gitlab::Email::SentNotificationNotFoundError)
+ it "raises a UnknownIncomingEmail" do
+ expect { receiver.execute }.to raise_error(Gitlab::Email::UnknownIncomingEmail)
end
end