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
Kazuhiko Shiozaki
gitlab-ce
Commits
00ec81ea
Commit
00ec81ea
authored
May 20, 2012
by
Robb Kidd
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update IssueObserver to send reassigned emails when an issue is reassigned.
parent
2416e3cb
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
44 additions
and
34 deletions
+44
-34
app/models/issue_observer.rb
app/models/issue_observer.rb
+8
-5
spec/models/issue_observer_spec.rb
spec/models/issue_observer_spec.rb
+36
-29
No files found.
app/models/issue_observer.rb
View file @
00ec81ea
...
@@ -6,12 +6,15 @@ class IssueObserver < ActiveRecord::Observer
...
@@ -6,12 +6,15 @@ class IssueObserver < ActiveRecord::Observer
end
end
def
after_change
(
issue
)
def
after_change
(
issue
)
if
issue
.
assignee_id_changed?
send_reassigned_email
(
issue
)
if
issue
.
is_being_reassigned?
end
def
send_reassigned_email
(
issue
)
recipient_ids
=
[
issue
.
assignee_id
,
issue
.
assignee_id_was
].
keep_if
{
|
id
|
id
!=
current_user
.
id
}
recipient_ids
=
[
issue
.
assignee_id
,
issue
.
assignee_id_was
].
keep_if
{
|
id
|
id
!=
current_user
.
id
}
recipient_ids
.
each
do
|
recipient_id
|
recipient_ids
.
each
do
|
recipient_id
|
Notify
.
reassigned_issue_email
(
recipient_id
,
issue
.
id
,
issue
.
assignee_id_was
)
Notify
.
reassigned_issue_email
(
recipient_id
,
issue
.
id
,
issue
.
assignee_id_was
)
end
end
end
end
end
end
end
spec/models/issue_observer_spec.rb
View file @
00ec81ea
require
'spec_helper'
require
'spec_helper'
describe
IssueObserver
do
describe
IssueObserver
do
let
(
:some_user
)
{
Factory
.
new
(
:user
,
:id
=>
1
)
}
let
(
:some_user
)
{
double
(
:user
,
:id
=>
1
)
}
let
(
:assignee
)
{
Factory
.
new
(
:user
,
:id
=>
2
)
}
let
(
:assignee
)
{
double
(
:user
,
:id
=>
2
)
}
let
(
:issue
)
{
Factory
.
new
(
:issue
,
:id
=>
42
,
:assignee
=>
assignee
)
}
let
(
:issue
)
{
double
(
:issue
,
:id
=>
42
,
:assignee
=>
assignee
)
}
before
(
:each
)
{
subject
.
stub
(
:current_user
).
and_return
(
some_user
)
}
before
(
:each
)
{
subject
.
stub
(
:current_user
).
and_return
(
some_user
)
}
...
@@ -25,19 +25,27 @@ describe IssueObserver do
...
@@ -25,19 +25,27 @@ describe IssueObserver do
end
end
end
end
context
'when an issue is
modifi
ed'
do
context
'when an issue is
chang
ed'
do
it
'
but not reassigned, does not send a reassigned email
'
do
it
'
sends a reassigned email, if the issue is being reassigned
'
do
issue
.
s
tub
(
:assignee_id_changed?
).
and_return
(
fals
e
)
issue
.
s
hould_receive
(
:is_being_reassigned?
).
and_return
(
tru
e
)
Notify
.
should_not_receive
(
:reassigned_issue_email
)
subject
.
should_receive
(
:send_reassigned_email
).
with
(
issue
)
subject
.
after_change
(
issue
)
subject
.
after_change
(
issue
)
end
end
context
'and is reassigned'
do
it
'does not send a reassigned email, if the issue was not reassigned'
do
let
(
:previous_assignee
)
{
Factory
.
new
(
:user
,
:id
=>
3
)
}
issue
.
should_receive
(
:is_being_reassigned?
).
and_return
(
false
)
subject
.
should_not_receive
(
:send_reassigned_email
)
subject
.
after_change
(
issue
)
end
end
describe
'#send_reassigned_email'
do
let
(
:previous_assignee
)
{
double
(
:user
,
:id
=>
3
)
}
before
(
:each
)
do
before
(
:each
)
do
issue
.
stub
(
:assignee_id_changed?
).
and_return
(
true
)
issue
.
stub
(
:assignee_id
).
and_return
(
assignee
.
id
)
issue
.
stub
(
:assignee_id_was
).
and_return
(
previous_assignee
.
id
)
issue
.
stub
(
:assignee_id_was
).
and_return
(
previous_assignee
.
id
)
end
end
...
@@ -45,7 +53,7 @@ describe IssueObserver do
...
@@ -45,7 +53,7 @@ describe IssueObserver do
Notify
.
should_receive
(
:reassigned_issue_email
).
with
(
assignee
.
id
,
issue
.
id
,
previous_assignee
.
id
)
Notify
.
should_receive
(
:reassigned_issue_email
).
with
(
assignee
.
id
,
issue
.
id
,
previous_assignee
.
id
)
Notify
.
should_receive
(
:reassigned_issue_email
).
with
(
previous_assignee
.
id
,
issue
.
id
,
previous_assignee
.
id
)
Notify
.
should_receive
(
:reassigned_issue_email
).
with
(
previous_assignee
.
id
,
issue
.
id
,
previous_assignee
.
id
)
subject
.
after_change
(
issue
)
subject
.
send_reassigned_email
(
issue
)
end
end
context
'does not send an email to the user who made the reassignment'
do
context
'does not send an email to the user who made the reassignment'
do
...
@@ -53,14 +61,13 @@ describe IssueObserver do
...
@@ -53,14 +61,13 @@ describe IssueObserver do
subject
.
stub
(
:current_user
).
and_return
(
assignee
)
subject
.
stub
(
:current_user
).
and_return
(
assignee
)
Notify
.
should_not_receive
(
:reassigned_issue_email
).
with
(
assignee
.
id
,
issue
.
id
,
previous_assignee
.
id
)
Notify
.
should_not_receive
(
:reassigned_issue_email
).
with
(
assignee
.
id
,
issue
.
id
,
previous_assignee
.
id
)
subject
.
after_change
(
issue
)
subject
.
send_reassigned_email
(
issue
)
end
end
it
'if the user is the previous assignee'
do
it
'if the user is the previous assignee'
do
subject
.
stub
(
:current_user
).
and_return
(
previous_assignee
)
subject
.
stub
(
:current_user
).
and_return
(
previous_assignee
)
Notify
.
should_not_receive
(
:reassigned_issue_email
).
with
(
previous_assignee
.
id
,
issue
.
id
,
previous_assignee
.
id
)
Notify
.
should_not_receive
(
:reassigned_issue_email
).
with
(
previous_assignee
.
id
,
issue
.
id
,
previous_assignee
.
id
)
subject
.
after_change
(
issue
)
subject
.
send_reassigned_email
(
issue
)
end
end
end
end
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