BigW Consortium Gitlab
Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gitlab-ce
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Forest Godfrey
gitlab-ce
Commits
e37c39a2
Commit
e37c39a2
authored
Aug 19, 2016
by
Sean McGivern
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix force-push message in push emails
`after_sha` maps to the source branch, as it's the head of our compare, so these were just the wrong way around.
parent
12fe6a6f
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
31 additions
and
8 deletions
+31
-8
emails_on_push_worker.rb
app/workers/emails_on_push_worker.rb
+2
-2
emails_on_push_worker_spec.rb
spec/workers/emails_on_push_worker_spec.rb
+29
-6
No files found.
app/workers/emails_on_push_worker.rb
View file @
e37c39a2
...
...
@@ -33,13 +33,13 @@ class EmailsOnPushWorker
reverse_compare
=
false
if
action
==
:push
compare
=
CompareService
.
new
.
execute
(
project
,
before_sha
,
project
,
after
_sha
)
compare
=
CompareService
.
new
.
execute
(
project
,
after_sha
,
project
,
before
_sha
)
diff_refs
=
compare
.
diff_refs
return
false
if
compare
.
same
if
compare
.
commits
.
empty?
compare
=
CompareService
.
new
.
execute
(
project
,
after_sha
,
project
,
before
_sha
)
compare
=
CompareService
.
new
.
execute
(
project
,
before_sha
,
project
,
after
_sha
)
diff_refs
=
compare
.
diff_refs
reverse_compare
=
true
...
...
spec/workers/emails_on_push_worker_spec.rb
View file @
e37c39a2
...
...
@@ -2,19 +2,19 @@ require 'spec_helper'
describe
EmailsOnPushWorker
do
include
RepoHelpers
include
EmailSpec
::
Matchers
let
(
:project
)
{
create
(
:project
)
}
let
(
:user
)
{
create
(
:user
)
}
let
(
:data
)
{
Gitlab
::
DataBuilder
::
Push
.
build_sample
(
project
,
user
)
}
let
(
:recipients
)
{
user
.
email
}
let
(
:perform
)
{
subject
.
perform
(
project
.
id
,
recipients
,
data
.
stringify_keys
)
}
let
(
:email
)
{
ActionMailer
::
Base
.
deliveries
.
last
}
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
)
...
...
@@ -31,8 +31,6 @@ describe EmailsOnPushWorker do
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
)
...
...
@@ -48,15 +46,40 @@ describe EmailsOnPushWorker do
end
end
context
"when there are no errors in sending"
do
let
(
:email
)
{
ActionMailer
::
Base
.
deliveries
.
last
}
context
"when push is a force push to delete commits"
do
before
do
data_force_push
=
data
.
stringify_keys
.
merge
(
"after"
=>
data
[
:before
],
"before"
=>
data
[
:after
]
)
subject
.
perform
(
project
.
id
,
recipients
,
data_force_push
)
end
it
"sends a mail with the correct subject"
do
expect
(
email
.
subject
).
to
include
(
'Change some files'
)
end
it
"mentions force pushing in the body"
do
expect
(
email
).
to
have_body_text
(
"force push"
)
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
before
{
perform
}
it
"sends a mail with the correct subject"
do
expect
(
email
.
subject
).
to
include
(
'Change some files'
)
end
it
"does not mention force pushing in the body"
do
expect
(
email
).
not_to
have_body_text
(
"force push"
)
end
it
"sends the mail to the correct recipient"
do
expect
(
email
.
to
).
to
eq
([
user
.
email
])
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