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
9da03c45
Commit
9da03c45
authored
Feb 16, 2016
by
Douglas Barbosa Alexandre
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Mark pending tasks for the current user as done when he edit a note
parent
49cd1965
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
60 additions
and
0 deletions
+60
-0
app/services/notes/update_service.rb
app/services/notes/update_service.rb
+4
-0
app/services/task_service.rb
app/services/task_service.rb
+11
-0
spec/services/notes/update_service_spec.rb
spec/services/notes/update_service_spec.rb
+45
-0
No files found.
app/services/notes/update_service.rb
View file @
9da03c45
...
@@ -7,6 +7,10 @@ module Notes
...
@@ -7,6 +7,10 @@ module Notes
note
.
create_new_cross_references!
(
current_user
)
note
.
create_new_cross_references!
(
current_user
)
note
.
reset_events_cache
note
.
reset_events_cache
if
note
.
previous_changes
.
include?
(
'note'
)
TaskService
.
new
.
update_note
(
note
,
current_user
)
end
note
note
end
end
end
end
...
...
app/services/task_service.rb
View file @
9da03c45
...
@@ -54,6 +54,17 @@ class TaskService
...
@@ -54,6 +54,17 @@ class TaskService
end
end
end
end
# When update a note we should:
#
# * mark all pending tasks related to the noteable for the current user as done
#
def
update_note
(
note
,
current_user
)
# Skip system notes, like status changes and cross-references
unless
note
.
system
mark_as_done
(
note
.
noteable
,
current_user
)
end
end
private
private
def
create_task
(
project
,
target
,
author
,
user
,
action
)
def
create_task
(
project
,
target
,
author
,
user
,
action
)
...
...
spec/services/notes/update_service_spec.rb
0 → 100644
View file @
9da03c45
require
'spec_helper'
describe
Notes
::
UpdateService
,
services:
true
do
let
(
:project
)
{
create
(
:empty_project
)
}
let
(
:user
)
{
create
(
:user
)
}
let
(
:user2
)
{
create
(
:user
)
}
let
(
:issue
)
{
create
(
:issue
,
project:
project
)
}
let
(
:note
)
{
create
(
:note
,
project:
project
,
noteable:
issue
,
author:
user
,
note:
'Old note'
)
}
before
do
project
.
team
<<
[
user
,
:master
]
project
.
team
<<
[
user2
,
:developer
]
end
describe
'#execute'
do
def
update_note
(
opts
)
@note
=
Notes
::
UpdateService
.
new
(
project
,
user
,
opts
).
execute
(
note
)
@note
.
reload
end
context
'task queue'
do
let!
(
:task
)
{
create
(
:pending_assigned_task
,
user:
user
,
project:
project
,
target:
issue
,
author:
user2
)
}
context
'when the note change'
do
before
do
update_note
({
note:
'New note'
})
end
it
'marks pending tasks as done'
do
expect
(
task
.
reload
).
to
be_done
end
end
context
'when the note does not change'
do
before
do
update_note
({
note:
'Old note'
})
end
it
'keep pending tasks'
do
expect
(
task
.
reload
).
to
be_pending
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