BigW Consortium Gitlab
Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gitlab-ce
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Forest Godfrey
gitlab-ce
Commits
1f5d5590
Commit
1f5d5590
authored
May 24, 2016
by
Lin Jen-Shin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Merge the places where exceptions could be raised
parent
863d8e5a
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
16 additions
and
6 deletions
+16
-6
email_receiver_worker.rb
app/workers/email_receiver_worker.rb
+2
-0
create_issue_handler.rb
lib/gitlab/email/handler/create_issue_handler.rb
+2
-1
create_note_handler.rb
lib/gitlab/email/handler/create_note_handler.rb
+2
-1
receiver.rb
lib/gitlab/email/receiver.rb
+2
-4
receiver_spec.rb
spec/lib/gitlab/email/receiver_spec.rb
+8
-0
No files found.
app/workers/email_receiver_worker.rb
View file @
1f5d5590
...
...
@@ -24,6 +24,8 @@ class EmailReceiverWorker
reason
=
nil
case
e
when
Gitlab
::
Email
::
UnknownIncomingEmail
reason
=
"We couldn't figure out what the email is for."
when
Gitlab
::
Email
::
SentNotificationNotFoundError
reason
=
"We couldn't figure out what the email is in reply to. Please create your comment through the web interface."
when
Gitlab
::
Email
::
ProjectNotFound
...
...
lib/gitlab/email/handler/create_issue_handler.rb
View file @
1f5d5590
...
...
@@ -14,10 +14,11 @@ module Gitlab
end
def
can_handle?
!!
(
project_namespace
&&
project
)
!!
authentication_token
end
def
execute
raise
ProjectNotFound
unless
project
validate_permission!
(
:create_issue
)
verify_record!
(
...
...
lib/gitlab/email/handler/create_note_handler.rb
View file @
1f5d5590
...
...
@@ -6,7 +6,8 @@ module Gitlab
module
Handler
class
CreateNoteHandler
<
BaseHandler
def
can_handle?
!!
(
mail_key
&&
sent_notification
)
# We want to raise SentNotificationNotFoundError for missing key
!!
(
mail_key
.
nil?
||
mail_key
=~
/\A\w+\z/
)
end
def
execute
...
...
lib/gitlab/email/receiver.rb
View file @
1f5d5590
...
...
@@ -16,6 +16,7 @@ module Gitlab
class
NoteableNotFoundError
<
ProcessingError
;
end
class
InvalidNoteError
<
ProcessingError
;
end
class
InvalidIssueError
<
ProcessingError
;
end
class
UnknownIncomingEmail
<
ProcessingError
;
end
class
Receiver
def
initialize
(
raw
)
...
...
@@ -30,11 +31,8 @@ module Gitlab
if
handler
=
Handler
.
for
(
mail
,
mail_key
)
handler
.
execute
elsif
mail_key
=~
%r{/|
\+
}
# Sent Notification mail_key would not have / or +
raise
ProjectNotFound
else
raise
SentNotificationNotFoundError
raise
UnknownIncomingEmail
end
end
...
...
spec/lib/gitlab/email/receiver_spec.rb
View file @
1f5d5590
...
...
@@ -30,6 +30,14 @@ describe Gitlab::Email::Receiver, lib: true do
)
end
context
"when we cannot find a capable handler"
do
let
(
:email_raw
)
{
fixture_file
(
'emails/valid_reply.eml'
).
gsub
(
mail_key
,
"!!!"
)
}
it
"raises a UnknownIncomingEmail"
do
expect
{
receiver
.
execute
}.
to
raise_error
(
Gitlab
::
Email
::
UnknownIncomingEmail
)
end
end
context
"when the recipient address doesn't include a mail key"
do
let
(
:email_raw
)
{
fixture_file
(
'emails/valid_reply.eml'
).
gsub
(
mail_key
,
""
)
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment