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
Jérome Perrin
gitlab-ce
Commits
9d9b7212
Commit
9d9b7212
authored
Aug 12, 2016
by
Douwe Maan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add specs for system note and email when all discussions are resolved
parent
e2572004
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
111 additions
and
0 deletions
+111
-0
spec/mailers/emails/merge_requests_spec.rb
spec/mailers/emails/merge_requests_spec.rb
+19
-0
spec/services/merge_requests/all_discussions_resolved_service_spec.rb
...s/merge_requests/all_discussions_resolved_service_spec.rb
+46
-0
spec/services/notification_service_spec.rb
spec/services/notification_service_spec.rb
+46
-0
No files found.
spec/mailers/emails/merge_requests_spec.rb
0 → 100644
View file @
9d9b7212
require
'spec_helper'
require
'email_spec'
require
'mailers/shared/notify'
describe
Notify
,
"merge request notifications"
do
include
EmailSpec
::
Matchers
describe
"#resolved_all_discussions_email"
do
let
(
:user
)
{
create
(
:user
)
}
let
(
:merge_request
)
{
create
(
:merge_request
)
}
let
(
:current_user
)
{
create
(
:user
)
}
subject
{
Notify
.
resolved_all_discussions_email
(
user
.
id
,
merge_request
.
id
,
current_user
.
id
)
}
it
"includes the name of the resolver"
do
expect
(
subject
).
to
have_body_text
current_user
.
name
end
end
end
spec/services/merge_requests/all_discussions_resolved_service_spec.rb
0 → 100644
View file @
9d9b7212
require
'spec_helper'
describe
MergeRequests
::
AllDiscussionsResolvedService
,
services:
true
do
let
(
:merge_request
)
{
create
(
:merge_request
)
}
let
(
:user
)
{
create
(
:user
)
}
let
(
:project
)
{
merge_request
.
project
}
subject
{
described_class
.
new
(
project
,
user
)
}
describe
"#execute"
do
context
"when not all discussions are resolved"
do
before
do
allow
(
merge_request
).
to
receive
(
:discussions_resolved?
).
and_return
(
false
)
end
it
"doesn't add a system note"
do
expect
(
SystemNoteService
).
not_to
receive
(
:resolve_all_discussions
)
subject
.
execute
(
merge_request
)
end
it
"doesn't send a notification email"
do
expect_any_instance_of
(
NotificationService
).
not_to
receive
(
:resolve_all_discussions
)
subject
.
execute
(
merge_request
)
end
end
context
"when all discussions are resolved"
do
before
do
allow
(
merge_request
).
to
receive
(
:discussions_resolved?
).
and_return
(
true
)
end
it
"adds a system note"
do
expect
(
SystemNoteService
).
to
receive
(
:resolve_all_discussions
).
with
(
merge_request
,
project
,
user
)
subject
.
execute
(
merge_request
)
end
it
"sends a notification email"
do
expect_any_instance_of
(
NotificationService
).
to
receive
(
:resolve_all_discussions
).
with
(
merge_request
,
user
)
subject
.
execute
(
merge_request
)
end
end
end
end
spec/services/notification_service_spec.rb
View file @
9d9b7212
...
...
@@ -1004,6 +1004,52 @@ describe NotificationService, services: true do
end
end
end
describe
"#resolve_all_discussions"
do
it
do
notification
.
resolve_all_discussions
(
merge_request
,
@u_disabled
)
should_email
(
merge_request
.
assignee
)
should_email
(
@u_watcher
)
should_email
(
@u_participant_mentioned
)
should_email
(
@subscriber
)
should_email
(
@watcher_and_subscriber
)
should_email
(
@u_guest_watcher
)
should_not_email
(
@unsubscriber
)
should_not_email
(
@u_participating
)
should_not_email
(
@u_disabled
)
should_not_email
(
@u_lazy_participant
)
end
context
'participating'
do
context
'by assignee'
do
before
do
merge_request
.
update_attribute
(
:assignee
,
@u_lazy_participant
)
notification
.
resolve_all_discussions
(
merge_request
,
@u_disabled
)
end
it
{
should_email
(
@u_lazy_participant
)
}
end
context
'by note'
do
let!
(
:note
)
{
create
(
:note_on_issue
,
noteable:
merge_request
,
project_id:
project
.
id
,
note:
'anything'
,
author:
@u_lazy_participant
)
}
before
{
notification
.
resolve_all_discussions
(
merge_request
,
@u_disabled
)
}
it
{
should_email
(
@u_lazy_participant
)
}
end
context
'by author'
do
before
do
merge_request
.
author
=
@u_lazy_participant
merge_request
.
save
notification
.
resolve_all_discussions
(
merge_request
,
@u_disabled
)
end
it
{
should_email
(
@u_lazy_participant
)
}
end
end
end
end
describe
'Projects'
do
...
...
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