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
c7bd99b0
Commit
c7bd99b0
authored
Mar 26, 2013
by
Dmitriy Zaporozhets
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refactor issue observer spec
parent
e3e8b9fc
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
16 additions
and
66 deletions
+16
-66
issue_observer_spec.rb
spec/observers/issue_observer_spec.rb
+16
-65
notification_service_spec.rb
spec/services/notification_service_spec.rb
+0
-1
No files found.
spec/observers/issue_observer_spec.rb
View file @
c7bd99b0
...
...
@@ -11,7 +11,9 @@ describe IssueObserver do
let
(
:closed_unassigned_issue
)
{
create
(
:closed_issue
,
author:
author
)
}
before
(
:each
)
{
subject
.
stub
(
:current_user
).
and_return
(
some_user
)
}
before
{
subject
.
stub
(
:current_user
).
and_return
(
some_user
)
}
before
{
subject
.
stub
(
notification:
mock
(
'NotificationService'
).
as_null_object
)
}
subject
{
IssueObserver
.
instance
}
...
...
@@ -25,15 +27,8 @@ describe IssueObserver do
end
end
it
'sends an email to the assignee'
do
Notify
.
should_receive
(
:new_issue_email
).
with
(
mock_issue
.
id
)
subject
.
after_create
(
mock_issue
)
end
it
'does not send an email to the assignee if assignee created the issue'
do
subject
.
stub
(
:current_user
).
and_return
(
assignee
)
Notify
.
should_not_receive
(
:new_issue_email
)
it
'trigger notification to send emails'
do
subject
.
should_receive
(
:notification
)
subject
.
after_create
(
mock_issue
)
end
...
...
@@ -47,16 +42,14 @@ describe IssueObserver do
assigned_issue
.
close
end
it
'
notification is delivered if the issue being closed
'
do
Notify
.
should_receive
(
:issue_status_changed_email
).
twice
it
'
trigger notification to send emails
'
do
subject
.
should_receive
(
:notification
)
assigned_issue
.
close
end
it
'notification is delivered only to author if the issue being closed'
do
Notify
.
should_receive
(
:issue_status_changed_email
).
once
it
'creates a note'
do
Note
.
should_receive
(
:create_status_change_note
).
with
(
unassigned_issue
,
some_user
,
'closed'
)
unassigned_issue
.
close
end
end
...
...
@@ -68,14 +61,13 @@ describe IssueObserver do
closed_assigned_issue
.
reopen
end
it
'
notification is delivered if the issue being reopened
'
do
Notify
.
should_receive
(
:issue_status_changed_email
).
twice
it
'
trigger notification to send emails
'
do
subject
.
should_receive
(
:notification
)
closed_assigned_issue
.
reopen
end
it
'notification is delivered only to author if the issue being reopened'
do
Notify
.
should_receive
(
:issue_status_changed_email
).
once
it
'create a note'
do
Note
.
should_receive
(
:create_status_change_note
).
with
(
closed_unassigned_issue
,
some_user
,
'reopened'
)
closed_unassigned_issue
.
reopen
...
...
@@ -98,61 +90,20 @@ describe IssueObserver do
end
end
context
'
a reassigned email
'
do
it
'
is sent
if the issue is being reassigned'
do
context
'
notification
'
do
it
'
triggered
if the issue is being reassigned'
do
mock_issue
.
should_receive
(
:is_being_reassigned?
).
and_return
(
true
)
subject
.
should_receive
(
:
send_reassigned_email
).
with
(
mock_issue
)
subject
.
should_receive
(
:
notification
)
subject
.
after_update
(
mock_issue
)
end
it
'is not
sent
if the issue is not being reassigned'
do
it
'is not
triggered
if the issue is not being reassigned'
do
mock_issue
.
should_receive
(
:is_being_reassigned?
).
and_return
(
false
)
subject
.
should_not_receive
(
:
send_reassigned_email
)
subject
.
should_not_receive
(
:
notification
)
subject
.
after_update
(
mock_issue
)
end
end
end
describe
'#send_reassigned_email'
do
let
(
:previous_assignee
)
{
double
(
:user
,
id:
3
)
}
before
(
:each
)
do
mock_issue
.
stub
(
:assignee_id
).
and_return
(
assignee
.
id
)
mock_issue
.
stub
(
:assignee_id_was
).
and_return
(
previous_assignee
.
id
)
end
def
it_sends_a_reassigned_email_to
(
recipient
)
Notify
.
should_receive
(
:reassigned_issue_email
).
with
(
recipient
,
mock_issue
.
id
,
previous_assignee
.
id
)
end
def
it_does_not_send_a_reassigned_email_to
(
recipient
)
Notify
.
should_not_receive
(
:reassigned_issue_email
).
with
(
recipient
,
mock_issue
.
id
,
previous_assignee
.
id
)
end
it
'sends a reassigned email to the previous and current assignees'
do
it_sends_a_reassigned_email_to
assignee
.
id
it_sends_a_reassigned_email_to
previous_assignee
.
id
subject
.
send
(
:send_reassigned_email
,
mock_issue
)
end
context
'does not send an email to the user who made the reassignment'
do
it
'if the user is the assignee'
do
subject
.
stub
(
:current_user
).
and_return
(
assignee
)
it_sends_a_reassigned_email_to
previous_assignee
.
id
it_does_not_send_a_reassigned_email_to
assignee
.
id
subject
.
send
(
:send_reassigned_email
,
mock_issue
)
end
it
'if the user is the previous assignee'
do
subject
.
stub
(
:current_user
).
and_return
(
previous_assignee
)
it_sends_a_reassigned_email_to
assignee
.
id
it_does_not_send_a_reassigned_email_to
previous_assignee
.
id
subject
.
send
(
:send_reassigned_email
,
mock_issue
)
end
end
end
end
spec/services/notification_service_spec.rb
View file @
c7bd99b0
...
...
@@ -44,4 +44,3 @@ describe NotificationService do
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