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
5194f415
Commit
5194f415
authored
Apr 07, 2017
by
Sean McGivern
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Ensure Service Desk handler is first
parent
d1bec074
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
64 additions
and
0 deletions
+64
-0
spec/lib/gitlab/email/handler_spec.rb
spec/lib/gitlab/email/handler_spec.rb
+64
-0
No files found.
spec/lib/gitlab/email/handler_spec.rb
0 → 100644
View file @
5194f415
require
'spec_helper'
describe
Gitlab
::
Email
::
Handler
,
lib:
true
do
before
do
stub_incoming_email_setting
(
enabled:
true
,
address:
"incoming+%{key}@appmail.adventuretime.ooo"
)
stub_config_setting
(
host:
'localhost'
)
end
let
(
:email_raw
)
{
fixture_file
(
'emails/service_desk.eml'
)
}
let
(
:email_raw
)
{
fixture_file
(
'emails/valid_new_issue.eml'
)
}
let
(
:email_raw
)
{
fixture_file
(
'emails/valid_reply.eml'
)
}
let
(
:email_raw
)
{
fixture_file
(
'emails/valid_reply.eml'
).
gsub
(
mail_key
,
"
#{
mail_key
}
+unsubscribe"
)
}
let!
(
:project
)
{
create
(
:empty_project
)
}
let!
(
:user
)
do
create
(
:user
,
email:
'jake@adventuretime.ooo'
,
incoming_email_token:
'auth_token'
)
end
describe
'.for'
do
def
handler_for
(
fixture
,
mail_key
)
described_class
.
for
(
fixture_file
(
fixture
),
mail_key
)
end
context
'a Service Desk email'
do
it
'uses the Service Desk handler when Service Desk is enabled'
do
allow_any_instance_of
(
License
).
to
receive
(
:add_on?
).
and_call_original
allow_any_instance_of
(
License
).
to
receive
(
:add_on?
).
with
(
'GitLab_ServiceDesk'
).
and_return
(
true
)
expect
(
handler_for
(
'emails/service_desk.eml'
,
'service_desk+auth_token'
)).
to
be_instance_of
(
Gitlab
::
Email
::
Handler
::
EE
::
ServiceDeskHandler
)
end
it
'uses the create issue handler when Service Desk is disabled'
do
allow_any_instance_of
(
License
).
to
receive
(
:add_on?
).
and_call_original
allow_any_instance_of
(
License
).
to
receive
(
:add_on?
).
with
(
'GitLab_ServiceDesk'
).
and_return
(
false
)
expect
(
handler_for
(
'emails/service_desk.eml'
,
'service_desk+auth_token'
)).
to
be_instance_of
(
Gitlab
::
Email
::
Handler
::
CreateIssueHandler
)
end
end
context
'a new issue email'
do
it
'uses the create issue handler when Service Desk is enabled'
do
allow_any_instance_of
(
License
).
to
receive
(
:add_on?
).
and_call_original
allow_any_instance_of
(
License
).
to
receive
(
:add_on?
).
with
(
'GitLab_ServiceDesk'
).
and_return
(
true
)
expect
(
handler_for
(
'emails/valid_new_issue.eml'
,
'incoming+auth_token'
)).
to
be_instance_of
(
Gitlab
::
Email
::
Handler
::
CreateIssueHandler
)
end
it
'uses the create issue handler when Service Desk is disabled'
do
allow_any_instance_of
(
License
).
to
receive
(
:add_on?
).
and_call_original
allow_any_instance_of
(
License
).
to
receive
(
:add_on?
).
with
(
'GitLab_ServiceDesk'
).
and_return
(
false
)
expect
(
handler_for
(
'emails/valid_new_issue.eml'
,
'incoming+auth_token'
)).
to
be_instance_of
(
Gitlab
::
Email
::
Handler
::
CreateIssueHandler
)
end
end
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