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
902f49e2
Commit
902f49e2
authored
Apr 05, 2017
by
Felipe Artur
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add license check for service desk
parent
152e5eda
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
39 additions
and
11 deletions
+39
-11
app/models/ee/project.rb
app/models/ee/project.rb
+7
-4
app/services/ee/notification_service.rb
app/services/ee/notification_service.rb
+2
-2
lib/ee/gitlab/service_desk.rb
lib/ee/gitlab/service_desk.rb
+9
-0
lib/gitlab/email/handler/ee/service_desk_handler.rb
lib/gitlab/email/handler/ee/service_desk_handler.rb
+1
-1
spec/lib/gitlab/email/handler/service_desk_handler_spec.rb
spec/lib/gitlab/email/handler/service_desk_handler_spec.rb
+20
-4
No files found.
app/models/ee/project.rb
View file @
902f49e2
...
...
@@ -27,8 +27,7 @@ module EE
end
def
service_desk_address
return
nil
unless
::
Gitlab
::
EE
::
ServiceDesk
.
enabled?
return
nil
unless
self
.
service_desk_enabled?
return
nil
unless
service_desk_avaiable?
refresh_service_desk_key!
if
service_desk_mail_key
.
blank?
...
...
@@ -37,14 +36,18 @@ module EE
end
def
refresh_service_desk_key!
return
unless
::
Gitlab
::
EE
::
ServiceDesk
.
enabled?
return
unless
self
.
service_desk_enabled?
return
unless
service_desk_avaiable?
self
.
service_desk_mail_key
=
SentNotification
.
reply_key
end
private
def
service_desk_avaiable?
@service_desk_available
||=
EE
::
Gitlab
::
ServiceDesk
.
enabled?
&&
service_desk_enabled?
end
def
auto_refresh_service_desk_key
if
service_desk_mail_key
.
blank?
||
service_desk_enabled_changed?
refresh_service_desk_key!
...
...
app/services/ee/notification_service.rb
View file @
902f49e2
require
'
gitlab/ee
/service_desk'
require
'
ee/gitlab
/service_desk'
module
EE
module
NotificationService
...
...
@@ -9,7 +9,7 @@ module EE
end
def
send_service_desk_notification
(
note
)
return
unless
::
Gitlab
::
EE
::
ServiceDesk
.
enabled?
return
unless
EE
::
Gitlab
::
ServiceDesk
.
enabled?
return
unless
note
.
noteable_type
==
'Issue'
issue
=
note
.
noteable
...
...
lib/
gitlab/ee
/service_desk.rb
→
lib/
ee/gitlab
/service_desk.rb
View file @
902f49e2
module
Gitlab
module
EE
module
EE
module
Gitlab
module
ServiceDesk
def
self
.
enabled?
# TODO
true
::
License
.
current
&&
::
License
.
current
.
add_on?
(
'GitLab_ServiceDesk'
)
end
end
end
...
...
lib/gitlab/email/handler/ee/service_desk_handler.rb
View file @
902f49e2
...
...
@@ -6,7 +6,7 @@ module Gitlab
include
ReplyProcessing
def
can_handle?
Gitlab
::
EE
::
ServiceDesk
.
enabled?
&&
service_desk_key
.
present?
::
EE
::
Gitlab
::
ServiceDesk
.
enabled?
&&
service_desk_key
.
present?
end
def
execute
...
...
spec/lib/gitlab/email/handler/service_desk_handler_spec.rb
View file @
902f49e2
...
...
@@ -17,13 +17,16 @@ describe Gitlab::Email::Handler::EE::ServiceDeskHandler do
project
.
update
(
service_desk_mail_key:
'somemailkey'
)
allow
(
Notify
).
to
receive
(
:service_desk_thank_you_email
)
.
with
(
instance_of
(
Integer
)).
and_return
(
double
(
deliver_later!:
true
))
.
with
(
instance_of
(
Fixnum
)).
and_return
(
double
(
deliver_later!:
true
))
allow_any_instance_of
(
License
).
to
receive
(
:add_on?
).
and_call_original
allow_any_instance_of
(
License
).
to
receive
(
:add_on?
).
with
(
'GitLab_ServiceDesk'
)
{
true
}
end
it
'
receives
the email and creates issue'
do
it
'
sends thank you
the email and creates issue'
do
setup_attachment
expect
(
Notify
).
to
receive
(
:service_desk_thank_you_email
).
with
(
instance_of
(
Integer
))
expect
(
Notify
).
to
receive
(
:service_desk_thank_you_email
).
with
(
instance_of
(
Fixnum
))
expect
{
receiver
.
execute
}.
to
change
{
Issue
.
count
}.
by
(
1
)
...
...
@@ -42,12 +45,25 @@ describe Gitlab::Email::Handler::EE::ServiceDeskHandler do
.
and_return
(
nil
)
end
it
"
creates issue and does not send thank you email
"
do
it
"
does not send thank you email but create an issue
"
do
expect
(
Notify
).
not_to
receive
(
:service_desk_thank_you_email
)
expect
{
receiver
.
execute
}.
to
change
{
Issue
.
count
}.
by
(
1
)
end
end
context
'when license does not support service desk'
do
before
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'
)
{
false
}
end
it
'does not create an issue or send email'
do
expect
(
Notify
).
not_to
receive
(
:service_desk_thank_you_email
)
expect
{
receiver
.
execute
rescue
nil
}.
not_to
change
{
Issue
.
count
}
end
end
end
context
'when service desk is not enabled'
do
...
...
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