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
Tatuya Kamada
gitlab-ce
Commits
0e9c4a90
Commit
0e9c4a90
authored
Aug 16, 2016
by
Nick Thomas
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
DRY up the added update service specs, add two email helpers
parent
b62954db
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
49 additions
and
62 deletions
+49
-62
spec/services/issues/update_service_spec.rb
spec/services/issues/update_service_spec.rb
+4
-31
spec/services/merge_requests/update_service_spec.rb
spec/services/merge_requests/update_service_spec.rb
+3
-31
spec/support/email_helpers.rb
spec/support/email_helpers.rb
+10
-0
spec/support/updating_mentions_shared_examples.rb
spec/support/updating_mentions_shared_examples.rb
+32
-0
No files found.
spec/services/issues/update_service_spec.rb
View file @
0e9c4a90
...
...
@@ -320,37 +320,10 @@ describe Issues::UpdateService, services: true do
end
end
context
'updated user mentions'
do
let
(
:user4
)
{
create
(
:user
)
}
before
do
project
.
team
<<
[
user4
,
:developer
]
end
context
"in title"
do
before
do
perform_enqueued_jobs
{
update_issue
(
title:
user4
.
to_reference
)
}
end
it
'emails only the newly-mentioned user'
do
should_not_email
(
user
)
should_not_email
(
user2
)
should_not_email
(
user3
)
should_email
(
user4
)
end
end
context
'in description'
do
before
do
perform_enqueued_jobs
{
update_issue
(
description:
user4
.
to_reference
)
}
end
it
'emails only the newly-mentioned user'
do
should_not_email
(
user
)
should_not_email
(
user2
)
should_not_email
(
user3
)
should_email
(
user4
)
end
end
context
'updating mentions'
do
let
(
:mentionable
)
{
issue
}
include_examples
'updating mentions'
,
Issues
::
UpdateService
end
end
end
spec/services/merge_requests/update_service_spec.rb
View file @
0e9c4a90
...
...
@@ -226,37 +226,9 @@ describe MergeRequests::UpdateService, services: true do
end
end
context
'updated user mentions'
do
let
(
:user4
)
{
create
(
:user
)
}
before
do
project
.
team
<<
[
user4
,
:developer
]
end
context
'in title'
do
before
do
perform_enqueued_jobs
{
update_merge_request
(
title:
user4
.
to_reference
)
}
end
it
'emails only the newly-mentioned user'
do
should_not_email
(
user
)
should_not_email
(
user2
)
should_not_email
(
user3
)
should_email
(
user4
)
end
end
context
'in description'
do
before
do
perform_enqueued_jobs
{
update_merge_request
(
description:
user4
.
to_reference
)
}
end
it
'emails only the newly-mentioned user'
do
should_not_email
(
user
)
should_not_email
(
user2
)
should_not_email
(
user3
)
should_email
(
user4
)
end
end
context
'updating mentions'
do
let
(
:mentionable
)
{
merge_request
}
include_examples
'updating mentions'
,
MergeRequests
::
UpdateService
end
context
'when MergeRequest has tasks'
do
...
...
spec/support/email_helpers.rb
View file @
0e9c4a90
...
...
@@ -3,6 +3,16 @@ module EmailHelpers
ActionMailer
::
Base
.
deliveries
.
map
(
&
:to
).
flatten
.
count
(
user
.
email
)
==
1
end
def
reset_delivered_emails!
ActionMailer
::
Base
.
deliveries
.
clear
end
def
should_only_email
(
*
users
)
users
.
each
{
|
user
|
should_email
(
user
)
}
recipients
=
ActionMailer
::
Base
.
deliveries
.
flat_map
(
&
:to
)
expect
(
recipients
.
count
).
to
eq
(
users
.
count
)
end
def
should_email
(
user
)
expect
(
sent_to_user?
(
user
)).
to
be_truthy
end
...
...
spec/support/updating_mentions_shared_examples.rb
0 → 100644
View file @
0e9c4a90
RSpec
.
shared_examples
'updating mentions'
do
|
service_class
|
let
(
:mentioned_user
)
{
create
(
:user
)
}
let
(
:service_class
)
{
service_class
}
before
{
project
.
team
<<
[
mentioned_user
,
:developer
]
}
def
update_mentionable
(
opts
)
reset_delivered_emails!
perform_enqueued_jobs
do
service_class
.
new
(
project
,
user
,
opts
).
execute
(
mentionable
)
end
mentionable
.
reload
end
context
'in title'
do
before
{
update_mentionable
(
title:
mentioned_user
.
to_reference
)
}
it
'emails only the newly-mentioned user'
do
should_only_email
(
mentioned_user
)
end
end
context
'in description'
do
before
{
update_mentionable
(
description:
mentioned_user
.
to_reference
)
}
it
'emails only the newly-mentioned user'
do
should_only_email
(
mentioned_user
)
end
end
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