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
b13bed62
Commit
b13bed62
authored
Mar 23, 2015
by
Douwe Maan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Clean up code by using keyword arguments.
parent
bf235053
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
28 additions
and
16 deletions
+28
-16
app/mailers/emails/projects.rb
app/mailers/emails/projects.rb
+7
-1
app/models/project_services/emails_on_push_service.rb
app/models/project_services/emails_on_push_service.rb
+7
-1
app/workers/emails_on_push_worker.rb
app/workers/emails_on_push_worker.rb
+8
-8
spec/mailers/notify_spec.rb
spec/mailers/notify_spec.rb
+6
-6
No files found.
app/mailers/emails/projects.rb
View file @
b13bed62
...
...
@@ -16,7 +16,13 @@ module Emails
subject:
subject
(
"Project was moved"
))
end
def
repository_push_email
(
project_id
,
recipient
,
author_id
,
ref
,
action
,
compare
,
reverse_compare
=
false
,
send_from_committer_email
=
false
,
disable_diffs
=
false
)
def
repository_push_email
(
project_id
,
recipient
,
author_id
:,
ref
:,
action
:,
compare:
nil
,
reverse_compare:
false
,
send_from_committer_email:
false
,
disable_diffs:
false
)
@project
=
Project
.
find
(
project_id
)
@author
=
User
.
find
(
author_id
)
@reverse_compare
=
reverse_compare
...
...
app/models/project_services/emails_on_push_service.rb
View file @
b13bed62
...
...
@@ -42,7 +42,13 @@ class EmailsOnPushService < Service
def
execute
(
push_data
)
return
unless
supported_events
.
include?
(
push_data
[
:object_kind
])
EmailsOnPushWorker
.
perform_async
(
project_id
,
recipients
,
push_data
,
send_from_committer_email?
,
disable_diffs?
)
EmailsOnPushWorker
.
perform_async
(
project_id
,
recipients
,
push_data
,
send_from_committer_email:
send_from_committer_email?
,
disable_diffs:
disable_diffs?
)
end
def
send_from_committer_email?
...
...
app/workers/emails_on_push_worker.rb
View file @
b13bed62
class
EmailsOnPushWorker
include
Sidekiq
::
Worker
def
perform
(
project_id
,
recipients
,
push_data
,
send_from_committer_email
=
false
,
disable_diffs
=
false
)
def
perform
(
project_id
,
recipients
,
push_data
,
send_from_committer_email
:
false
,
disable_diffs:
false
)
project
=
Project
.
find
(
project_id
)
before_sha
=
push_data
[
"before"
]
after_sha
=
push_data
[
"after"
]
...
...
@@ -37,13 +37,13 @@ class EmailsOnPushWorker
Notify
.
repository_push_email
(
project_id
,
recipient
,
author_id
,
ref
,
action
,
compare
,
reverse_compare
,
send_from_committer_email
,
disable_diffs
author_id
:
author_id
,
ref
:
ref
,
action
:
action
,
compare
:
compare
,
reverse_compare
:
reverse_compare
,
send_from_committer_email
:
send_from_committer_email
,
disable_diffs
:
disable_diffs
).
deliver
end
ensure
...
...
spec/mailers/notify_spec.rb
View file @
b13bed62
...
...
@@ -645,7 +645,7 @@ describe Notify do
let
(
:user
)
{
create
(
:user
)
}
let
(
:tree_path
)
{
namespace_project_tree_path
(
project
.
namespace
,
project
,
"master"
)
}
subject
{
Notify
.
repository_push_email
(
project
.
id
,
'devs@company.name'
,
user
.
id
,
'refs/heads/master'
,
:create
,
nil
)
}
subject
{
Notify
.
repository_push_email
(
project
.
id
,
'devs@company.name'
,
author_id:
user
.
id
,
ref:
'refs/heads/master'
,
action: :create
)
}
it
'is sent as the author'
do
sender
=
subject
.
header
[
:from
].
addrs
[
0
]
...
...
@@ -671,7 +671,7 @@ describe Notify do
let
(
:user
)
{
create
(
:user
)
}
let
(
:tree_path
)
{
namespace_project_tree_path
(
project
.
namespace
,
project
,
"v1.0"
)
}
subject
{
Notify
.
repository_push_email
(
project
.
id
,
'devs@company.name'
,
user
.
id
,
'refs/tags/v1.0'
,
:create
,
nil
)
}
subject
{
Notify
.
repository_push_email
(
project
.
id
,
'devs@company.name'
,
author_id:
user
.
id
,
ref:
'refs/tags/v1.0'
,
action: :create
)
}
it
'is sent as the author'
do
sender
=
subject
.
header
[
:from
].
addrs
[
0
]
...
...
@@ -696,7 +696,7 @@ describe Notify do
let
(
:example_site_path
)
{
root_path
}
let
(
:user
)
{
create
(
:user
)
}
subject
{
Notify
.
repository_push_email
(
project
.
id
,
'devs@company.name'
,
user
.
id
,
'refs/heads/master'
,
:delete
,
nil
)
}
subject
{
Notify
.
repository_push_email
(
project
.
id
,
'devs@company.name'
,
author_id:
user
.
id
,
ref:
'refs/heads/master'
,
action: :delete
)
}
it
'is sent as the author'
do
sender
=
subject
.
header
[
:from
].
addrs
[
0
]
...
...
@@ -717,7 +717,7 @@ describe Notify do
let
(
:example_site_path
)
{
root_path
}
let
(
:user
)
{
create
(
:user
)
}
subject
{
Notify
.
repository_push_email
(
project
.
id
,
'devs@company.name'
,
user
.
id
,
'refs/tags/v1.0'
,
:delete
,
nil
)
}
subject
{
Notify
.
repository_push_email
(
project
.
id
,
'devs@company.name'
,
author_id:
user
.
id
,
ref:
'refs/tags/v1.0'
,
action: :delete
)
}
it
'is sent as the author'
do
sender
=
subject
.
header
[
:from
].
addrs
[
0
]
...
...
@@ -742,7 +742,7 @@ describe Notify do
let
(
:diff_path
)
{
namespace_project_compare_path
(
project
.
namespace
,
project
,
from:
Commit
.
new
(
compare
.
base
),
to:
Commit
.
new
(
compare
.
head
))
}
let
(
:send_from_committer_email
)
{
false
}
subject
{
Notify
.
repository_push_email
(
project
.
id
,
'devs@company.name'
,
user
.
id
,
'refs/heads/master'
,
:push
,
compare
,
false
,
send_from_committer_email
)
}
subject
{
Notify
.
repository_push_email
(
project
.
id
,
'devs@company.name'
,
author_id:
user
.
id
,
ref:
'refs/heads/master'
,
action: :push
,
compare:
compare
,
reverse_compare:
false
,
send_from_committer_email:
send_from_committer_email
)
}
it
'is sent as the author'
do
sender
=
subject
.
header
[
:from
].
addrs
[
0
]
...
...
@@ -830,7 +830,7 @@ describe Notify do
let
(
:commits
)
{
Commit
.
decorate
(
compare
.
commits
)
}
let
(
:diff_path
)
{
namespace_project_commit_path
(
project
.
namespace
,
project
,
commits
.
first
)
}
subject
{
Notify
.
repository_push_email
(
project
.
id
,
'devs@company.name'
,
user
.
id
,
'refs/heads/master'
,
:push
,
compare
)
}
subject
{
Notify
.
repository_push_email
(
project
.
id
,
'devs@company.name'
,
author_id:
user
.
id
,
ref:
'refs/heads/master'
,
action: :push
,
compare:
compare
)
}
it
'is sent as the author'
do
sender
=
subject
.
header
[
:from
].
addrs
[
0
]
...
...
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