Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
GitLab
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
projects.thm.de
GitLab
Commits
09cbe95b
Commit
09cbe95b
authored
Dec 26, 2013
by
Drew Blessing
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add note for assignee changes
Change to username per @PixnBits suggestion
parent
6579de07
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
48 additions
and
0 deletions
+48
-0
app/models/note.rb
app/models/note.rb
+12
-0
app/observers/issue_observer.rb
app/observers/issue_observer.rb
+5
-0
spec/models/note_spec.rb
spec/models/note_spec.rb
+31
-0
No files found.
app/models/note.rb
View file @
09cbe95b
...
...
@@ -82,6 +82,18 @@ def create_cross_reference_note(noteable, mentioner, author, project)
},
without_protection:
true
)
end
def
create_assignee_change_note
(
noteable
,
project
,
author
,
assignee
)
body
=
assignee
.
nil?
?
'_Assignee removed_'
:
"_Reassigned to @
#{
assignee
.
username
}
_"
create
({
noteable:
noteable
,
project:
project
,
author:
author
,
note:
body
,
system:
true
},
without_protection:
true
)
end
def
discussions_from_notes
(
notes
)
discussion_ids
=
[]
discussions
=
[]
...
...
app/observers/issue_observer.rb
View file @
09cbe95b
...
...
@@ -19,6 +19,7 @@ def after_reopen(issue, transition)
def
after_update
(
issue
)
if
issue
.
is_being_reassigned?
notification
.
reassigned_issue
(
issue
,
current_user
)
create_assignee_note
(
issue
)
end
issue
.
notice_added_references
(
issue
.
project
,
current_user
)
...
...
@@ -32,6 +33,10 @@ def create_note(issue)
Note
.
create_status_change_note
(
issue
,
issue
.
project
,
current_user
,
issue
.
state
,
current_commit
)
end
def
create_assignee_note
(
issue
)
Note
.
create_assignee_change_note
(
issue
,
issue
.
project
,
current_user
,
issue
.
assignee
)
end
def
execute_hooks
(
issue
)
issue
.
project
.
execute_hooks
(
issue
.
to_hook_data
,
:issue_hooks
)
end
...
...
spec/models/note_spec.rb
View file @
09cbe95b
...
...
@@ -180,6 +180,31 @@
end
end
describe
'#create_assignee_change_note'
do
let
(
:project
)
{
create
(
:project
)
}
let
(
:thing
)
{
create
(
:issue
,
project:
project
)
}
let
(
:author
)
{
create
(
:user
)
}
let
(
:assignee
)
{
create
(
:user
)
}
subject
{
Note
.
create_assignee_change_note
(
thing
,
project
,
author
,
assignee
)
}
context
'creates and saves a Note'
do
it
{
should
be_a
Note
}
its
(
:id
)
{
should_not
be_nil
}
end
its
(
:noteable
)
{
should
==
thing
}
its
(
:project
)
{
should
==
thing
.
project
}
its
(
:author
)
{
should
==
author
}
its
(
:note
)
{
should
=~
/Reassigned to @
#{
assignee
.
username
}
/
}
context
'assignee is removed'
do
let
(
:assignee
)
{
nil
}
its
(
:note
)
{
should
=~
/Assignee removed/
}
end
end
describe
'#create_cross_reference_note'
do
let
(
:project
)
{
create
(
:project_with_code
)
}
let
(
:author
)
{
create
(
:user
)
}
...
...
@@ -252,6 +277,7 @@
let
(
:issue
)
{
create
(
:issue
,
project:
project
)
}
let
(
:other
)
{
create
(
:issue
,
project:
project
)
}
let
(
:author
)
{
create
(
:user
)
}
let
(
:assignee
)
{
create
(
:user
)
}
it
'should recognize user-supplied notes as non-system'
do
@note
=
create
(
:note_on_issue
)
...
...
@@ -267,6 +293,11 @@
@note
=
Note
.
create_cross_reference_note
(
issue
,
other
,
author
,
project
)
@note
.
should
be_system
end
it
'should identify assignee-change notes as system notes'
do
@note
=
Note
.
create_assignee_change_note
(
issue
,
project
,
author
,
assignee
)
@note
.
should
be_system
end
end
describe
:authorization
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