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
152e5eda
Commit
152e5eda
authored
Apr 05, 2017
by
Felipe Artur
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix rubocop failures, create email even if from address it not found, fix specs
parent
7f6df32f
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
46 additions
and
14 deletions
+46
-14
app/models/ee/project.rb
app/models/ee/project.rb
+1
-0
app/policies/ee/project_policy.rb
app/policies/ee/project_policy.rb
+6
-0
app/services/ee/notification_service.rb
app/services/ee/notification_service.rb
+1
-2
db/migrate/20170404223037_add_service_desk_settings.rb
db/migrate/20170404223037_add_service_desk_settings.rb
+10
-1
lib/gitlab/email/handler/ee/service_desk_handler.rb
lib/gitlab/email/handler/ee/service_desk_handler.rb
+4
-3
spec/fixtures/emails/service_desk.eml
spec/fixtures/emails/service_desk.eml
+1
-1
spec/lib/gitlab/email/handler/service_desk_handler_spec.rb
spec/lib/gitlab/email/handler/service_desk_handler_spec.rb
+22
-6
spec/services/ee/notification_service_spec.rb
spec/services/ee/notification_service_spec.rb
+1
-1
No files found.
app/models/ee/project.rb
View file @
152e5eda
...
@@ -44,6 +44,7 @@ module EE
...
@@ -44,6 +44,7 @@ module EE
end
end
private
private
def
auto_refresh_service_desk_key
def
auto_refresh_service_desk_key
if
service_desk_mail_key
.
blank?
||
service_desk_enabled_changed?
if
service_desk_mail_key
.
blank?
||
service_desk_enabled_changed?
refresh_service_desk_key!
refresh_service_desk_key!
...
...
app/policies/ee/project_policy.rb
View file @
152e5eda
module
EE
module
EE
module
ProjectPolicy
module
ProjectPolicy
def
rules
super
guest_access!
if
user
.
support_bot?
end
def
disabled_features!
def
disabled_features!
raise
NotImplementedError
unless
defined?
(
super
)
raise
NotImplementedError
unless
defined?
(
super
)
...
...
app/services/ee/notification_service.rb
View file @
152e5eda
...
@@ -13,7 +13,6 @@ module EE
...
@@ -13,7 +13,6 @@ module EE
return
unless
note
.
noteable_type
==
'Issue'
return
unless
note
.
noteable_type
==
'Issue'
issue
=
note
.
noteable
issue
=
note
.
noteable
reply_to
=
issue
.
service_desk_reply_to
support_bot
=
::
User
.
support_bot
support_bot
=
::
User
.
support_bot
return
unless
issue
.
service_desk_reply_to
.
present?
return
unless
issue
.
service_desk_reply_to
.
present?
...
@@ -21,7 +20,7 @@ module EE
...
@@ -21,7 +20,7 @@ module EE
return
if
note
.
author
==
support_bot
return
if
note
.
author
==
support_bot
return
unless
issue
.
subscribed?
(
support_bot
,
issue
.
project
)
return
unless
issue
.
subscribed?
(
support_bot
,
issue
.
project
)
Notify
.
service_desk_new_note_email
(
issue
.
id
,
note
.
id
)
Notify
.
service_desk_new_note_email
(
issue
.
id
,
note
.
id
)
.
deliver_later
end
end
end
end
end
end
db/migrate/20170404223037_add_service_desk_settings.rb
View file @
152e5eda
...
@@ -23,7 +23,7 @@ class AddServiceDeskSettings < ActiveRecord::Migration
...
@@ -23,7 +23,7 @@ class AddServiceDeskSettings < ActiveRecord::Migration
# comments:
# comments:
disable_ddl_transaction!
disable_ddl_transaction!
def
change
def
up
add_column
:users
,
:support_bot
,
:boolean
add_column
:users
,
:support_bot
,
:boolean
add_column
:projects
,
:service_desk_enabled
,
:boolean
add_column
:projects
,
:service_desk_enabled
,
:boolean
...
@@ -34,4 +34,13 @@ class AddServiceDeskSettings < ActiveRecord::Migration
...
@@ -34,4 +34,13 @@ class AddServiceDeskSettings < ActiveRecord::Migration
add_concurrent_index
:users
,
:support_bot
add_concurrent_index
:users
,
:support_bot
add_concurrent_index
:projects
,
:service_desk_mail_key
,
unique:
true
add_concurrent_index
:projects
,
:service_desk_mail_key
,
unique:
true
end
end
def
down
remove_column
:users
,
:support_bot
remove_column
:projects
,
:service_desk_enabled
remove_column
:projects
,
:service_desk_mail_key
remove_column
:issues
,
:service_desk_reply_to
end
end
end
lib/gitlab/email/handler/ee/service_desk_handler.rb
View file @
152e5eda
...
@@ -10,11 +10,10 @@ module Gitlab
...
@@ -10,11 +10,10 @@ module Gitlab
end
end
def
execute
def
execute
raise
EmailUnparsableError
if
from_address
.
blank?
raise
ProjectNotFound
if
project
.
nil?
raise
ProjectNotFound
if
project
.
nil?
create_issue!
create_issue!
send_thank_you_email!
send_thank_you_email!
if
from_address
end
end
private
private
...
@@ -61,7 +60,9 @@ module Gitlab
...
@@ -61,7 +60,9 @@ module Gitlab
end
end
def
issue_title
def
issue_title
"Service Desk (from `
#{
from_address
}
`):
#{
mail
.
subject
}
"
from
=
"(from
#{
from_address
}
)"
if
from_address
"Service Desk
#{
from
}
:
#{
mail
.
subject
}
"
end
end
end
end
end
end
...
...
spec/fixtures/emails/service_desk.eml
View file @
152e5eda
...
@@ -5,7 +5,7 @@ Received: by mail-ie0-f180.google.com with SMTP id f4so21977375iea.25 for <incom
...
@@ -5,7 +5,7 @@ Received: by mail-ie0-f180.google.com with SMTP id f4so21977375iea.25 for <incom
Received: by 10.0.0.1 with HTTP; Thu, 13 Jun 2013 14:03:48 -0700
Received: by 10.0.0.1 with HTTP; Thu, 13 Jun 2013 14:03:48 -0700
Date: Thu, 13 Jun 2013 17:03:48 -0400
Date: Thu, 13 Jun 2013 17:03:48 -0400
From: Jake the Dog <jake@adventuretime.ooo>
From: Jake the Dog <jake@adventuretime.ooo>
To: incoming+service
-
desk+somemailkey@appmail.adventuretime.ooo
To: incoming+service
_
desk+somemailkey@appmail.adventuretime.ooo
Message-ID: <CADkmRc+rNGAGGbV2iE5p918UVy4UyJqVcXRO2=otppgzduJSg@mail.gmail.com>
Message-ID: <CADkmRc+rNGAGGbV2iE5p918UVy4UyJqVcXRO2=otppgzduJSg@mail.gmail.com>
Subject: The message subject! @all
Subject: The message subject! @all
Mime-Version: 1.0
Mime-Version: 1.0
...
...
spec/lib/gitlab/email/handler/service_desk_handler_spec.rb
View file @
152e5eda
...
@@ -13,16 +13,17 @@ describe Gitlab::Email::Handler::EE::ServiceDeskHandler do
...
@@ -13,16 +13,17 @@ describe Gitlab::Email::Handler::EE::ServiceDeskHandler do
context
'when service desk is enabled'
do
context
'when service desk is enabled'
do
before
do
before
do
project
.
update_attributes
(
project
.
update
(
service_desk_enabled:
true
)
service_desk_enabled:
true
,
project
.
update
(
service_desk_mail_key:
'somemailkey'
)
service_desk_mail_key:
'somemailkey'
,
)
allow
(
Notify
).
to
receive
(
:service_desk_thank_you_email
)
.
with
(
instance_of
(
Integer
)).
and_return
(
double
(
deliver_later!:
true
))
end
end
it
'receives the email'
do
it
'receives the email
and creates issue
'
do
setup_attachment
setup_attachment
expect
(
Notify
).
to
receive
(
:service_desk_thank_you_email
).
with
(
instance_of
(
Fixnum
))
expect
(
Notify
).
to
receive
(
:service_desk_thank_you_email
).
with
(
instance_of
(
Integer
))
expect
{
receiver
.
execute
}.
to
change
{
Issue
.
count
}.
by
(
1
)
expect
{
receiver
.
execute
}.
to
change
{
Issue
.
count
}.
by
(
1
)
...
@@ -31,6 +32,21 @@ describe Gitlab::Email::Handler::EE::ServiceDeskHandler do
...
@@ -31,6 +32,21 @@ describe Gitlab::Email::Handler::EE::ServiceDeskHandler do
expect
(
new_issue
.
author
).
to
eql
(
User
.
support_bot
)
expect
(
new_issue
.
author
).
to
eql
(
User
.
support_bot
)
expect
(
new_issue
.
confidential?
).
to
be
true
expect
(
new_issue
.
confidential?
).
to
be
true
expect
(
new_issue
.
all_references
.
all
).
to
be_empty
expect
(
new_issue
.
all_references
.
all
).
to
be_empty
expect
(
new_issue
.
title
).
to
eq
(
"Service Desk (from jake@adventuretime.ooo): The message subject! @all"
)
expect
(
new_issue
.
description
).
to
eq
(
"Service desk stuff!
\n\n
```
\n
a = b
\n
```
\n\n
![image](uploads/image.png)"
)
end
context
'when there is no from address'
do
before
do
allow_any_instance_of
(
described_class
).
to
receive
(
:from_address
)
.
and_return
(
nil
)
end
it
"creates issue and does not send thank you email"
do
expect
(
Notify
).
not_to
receive
(
:service_desk_thank_you_email
)
expect
{
receiver
.
execute
}.
to
change
{
Issue
.
count
}.
by
(
1
)
end
end
end
end
end
...
...
spec/services/ee/notification_service_spec.rb
View file @
152e5eda
...
@@ -4,7 +4,7 @@ describe EE::NotificationService do
...
@@ -4,7 +4,7 @@ describe EE::NotificationService do
let
(
:subject
)
{
NotificationService
.
new
}
let
(
:subject
)
{
NotificationService
.
new
}
def
should_email!
def
should_email!
expect
(
Notify
).
to
receive
(
:service_desk_new_note_email
).
with
(
issue
.
id
,
instance_of
(
Fixnum
))
expect
(
Notify
).
to
receive
(
:service_desk_new_note_email
).
with
(
issue
.
id
,
instance_of
(
Integer
))
end
end
def
should_not_email!
def
should_not_email!
...
...
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