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
0
Merge Requests
0
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
iv
gitlab-ce
Commits
331571e0
Commit
331571e0
authored
Jul 21, 2016
by
Sean McGivern
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix emails on push for new and deleted branches
parent
cb9f418b
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
38 additions
and
2 deletions
+38
-2
app/workers/emails_on_push_worker.rb
app/workers/emails_on_push_worker.rb
+2
-2
spec/workers/emails_on_push_worker_spec.rb
spec/workers/emails_on_push_worker_spec.rb
+36
-0
No files found.
app/workers/emails_on_push_worker.rb
View file @
331571e0
...
...
@@ -28,12 +28,12 @@ class EmailsOnPushWorker
:push
end
merge_base_sha
=
project
.
merge_base_commit
(
before_sha
,
after_sha
).
try
(
:sha
)
diff_refs
=
nil
compare
=
nil
reverse_compare
=
false
if
action
==
:push
merge_base_sha
=
project
.
merge_base_commit
(
before_sha
,
after_sha
).
try
(
:sha
)
compare
=
Gitlab
::
Git
::
Compare
.
new
(
project
.
repository
.
raw_repository
,
before_sha
,
after_sha
)
diff_refs
=
Gitlab
::
Diff
::
DiffRefs
.
new
(
...
...
spec/workers/emails_on_push_worker_spec.rb
View file @
331571e0
...
...
@@ -12,6 +12,42 @@ describe EmailsOnPushWorker do
subject
{
EmailsOnPushWorker
.
new
}
describe
"#perform"
do
context
"when push is a new branch"
do
let
(
:email
)
{
ActionMailer
::
Base
.
deliveries
.
last
}
before
do
data_new_branch
=
data
.
stringify_keys
.
merge
(
"before"
=>
Gitlab
::
Git
::
BLANK_SHA
)
subject
.
perform
(
project
.
id
,
recipients
,
data_new_branch
)
end
it
"sends a mail with the correct subject"
do
expect
(
email
.
subject
).
to
include
(
"Pushed new branch"
)
end
it
"sends the mail to the correct recipient"
do
expect
(
email
.
to
).
to
eq
([
user
.
email
])
end
end
context
"when push is a deleted branch"
do
let
(
:email
)
{
ActionMailer
::
Base
.
deliveries
.
last
}
before
do
data_deleted_branch
=
data
.
stringify_keys
.
merge
(
"after"
=>
Gitlab
::
Git
::
BLANK_SHA
)
subject
.
perform
(
project
.
id
,
recipients
,
data_deleted_branch
)
end
it
"sends a mail with the correct subject"
do
expect
(
email
.
subject
).
to
include
(
"Deleted branch"
)
end
it
"sends the mail to the correct recipient"
do
expect
(
email
.
to
).
to
eq
([
user
.
email
])
end
end
context
"when there are no errors in sending"
do
let
(
:email
)
{
ActionMailer
::
Base
.
deliveries
.
last
}
...
...
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