summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorDouwe Maan <douwe@gitlab.com>2015-08-20 12:17:59 -0700
committerDouwe Maan <douwe@gitlab.com>2015-08-20 12:17:59 -0700
commit8ec5fb138dde9937814ac138352177399d3e776d (patch)
tree722ca03ab54b8123b075e1b1ea0e01c4e0ff263a /lib
parente44936f3ed4799714fc36a342c1dbab1d50f0ffc (diff)
downloadgitlab-ce-8ec5fb138dde9937814ac138352177399d3e776d.tar.gz
Test Gitlab::Email::Receiver.
Diffstat (limited to 'lib')
-rw-r--r--lib/gitlab/email/receiver.rb18
1 files changed, 9 insertions, 9 deletions
diff --git a/lib/gitlab/email/receiver.rb b/lib/gitlab/email/receiver.rb
index 466e48b22e1..17b8339edcd 100644
--- a/lib/gitlab/email/receiver.rb
+++ b/lib/gitlab/email/receiver.rb
@@ -16,17 +16,11 @@ module Gitlab
@raw = raw
end
- def message
- @message ||= Mail::Message.new(@raw)
- rescue Encoding::UndefinedConversionError, Encoding::InvalidByteSequenceError => e
- raise EmailUnparsableError, e
- end
-
def execute
- raise SentNotificationNotFoundError unless sent_notification
-
raise EmptyEmailError if @raw.blank?
+ raise SentNotificationNotFoundError unless sent_notification
+
raise AutoGeneratedEmailError if message.header.to_s =~ /auto-(generated|replied)/
author = sent_notification.recipient
@@ -35,7 +29,7 @@ module Gitlab
project = sent_notification.project
- raise UserNotAuthorizedError unless author.can?(:create_note, project)
+ raise UserNotAuthorizedError unless project && author.can?(:create_note, project)
raise NoteableNotFoundError unless sent_notification.noteable
@@ -59,6 +53,12 @@ module Gitlab
private
+ def message
+ @message ||= Mail::Message.new(@raw)
+ rescue Encoding::UndefinedConversionError, Encoding::InvalidByteSequenceError => e
+ raise EmailUnparsableError, e
+ end
+
def reply_key
reply_key = nil
message.to.each do |address|