Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
8156475e
Commit
8156475e
authored
Apr 07, 2016
by
Lin Jen-Shin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Report better errors. TODO: Enable skipped test
parent
30b34437
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
31 additions
and
7 deletions
+31
-7
app/workers/email_receiver_worker.rb
app/workers/email_receiver_worker.rb
+2
-0
lib/gitlab/email/receiver.rb
lib/gitlab/email/receiver.rb
+9
-2
spec/lib/gitlab/email/receiver_spec.rb
spec/lib/gitlab/email/receiver_spec.rb
+20
-5
No files found.
app/workers/email_receiver_worker.rb
View file @
8156475e
...
...
@@ -26,6 +26,8 @@ class EmailReceiverWorker
case
e
when
Gitlab
::
Email
::
Receiver
::
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
::
Receiver
::
ProjectNotFound
reason
=
"We couldn't find the project. Please check if there's any typo."
when
Gitlab
::
Email
::
Receiver
::
EmptyEmailError
can_retry
=
true
reason
=
"It appears that the email is blank. Make sure your reply is at the top of the email, we can't process inline replies."
...
...
lib/gitlab/email/receiver.rb
View file @
8156475e
...
...
@@ -5,6 +5,7 @@ module Gitlab
class
ProcessingError
<
StandardError
;
end
class
EmailUnparsableError
<
ProcessingError
;
end
class
SentNotificationNotFoundError
<
ProcessingError
;
end
class
ProjectNotFound
<
ProcessingError
;
end
class
EmptyEmailError
<
ProcessingError
;
end
class
AutoGeneratedEmailError
<
ProcessingError
;
end
class
UserNotFoundError
<
ProcessingError
;
end
...
...
@@ -25,10 +26,16 @@ module Gitlab
process_create_note
elsif
message_project
if
message_sender
.
can?
(
:read_project
,
message_project
)
process_create_issue
else
# Must be private project without access
raise
ProjectNotFound
end
elsif
reply_key
=~
%r{/|
\+
}
# Sent Notification reply_key would not have / or +
raise
ProjectNotFound
else
# TODO: could also be project not found
raise
SentNotificationNotFoundError
end
end
...
...
spec/lib/gitlab/email/receiver_spec.rb
View file @
8156475e
...
...
@@ -210,10 +210,12 @@ describe Gitlab::Email::Receiver, lib: true do
end
context
"something is wrong"
do
context
"when the issue could not be saved"
do
before
do
project
end
context
"when the issue could not be saved"
do
before
do
allow_any_instance_of
(
Issue
).
to
receive
(
:persisted?
).
and_return
(
false
)
end
...
...
@@ -225,11 +227,24 @@ describe Gitlab::Email::Receiver, lib: true do
context
"when the authentication_token token didn't match"
do
let!
(
:email_raw
)
{
fixture_file
(
"emails/wrong_authentication_token.eml"
)
}
before
do
project
it
"raises an UserNotAuthorizedError"
do
expect
{
receiver
.
execute
}.
to
raise_error
(
Gitlab
::
Email
::
Receiver
::
UserNotAuthorizedError
)
end
end
it
"raises an UserNotAuthorizedError"
do
context
"when project is private"
do
let
(
:project
)
{
create
(
:project
,
:private
,
namespace:
namespace
)
}
it
"raises a ProjectNotFound if the user is not a member"
do
expect
{
receiver
.
execute
}.
to
raise_error
(
Gitlab
::
Email
::
Receiver
::
ProjectNotFound
)
end
it
"raises a UserNotAuthorizedError if the user has no sufficient permission"
do
skip
(
"Find a role which can :read_project but can't :create_issue"
)
project
.
update
(
group:
create
(
:group
))
project
.
group
.
add_guest
(
user
)
expect
{
receiver
.
execute
}.
to
raise_error
(
Gitlab
::
Email
::
Receiver
::
UserNotAuthorizedError
)
end
end
...
...
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