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
49cd1965
Commit
49cd1965
authored
Feb 16, 2016
by
Douglas Barbosa Alexandre
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Mark pending tasks for the note author as done when he left a note
parent
917081fe
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
53 additions
and
6 deletions
+53
-6
app/services/notes/post_process_service.rb
app/services/notes/post_process_service.rb
+2
-2
app/services/task_service.rb
app/services/task_service.rb
+11
-0
spec/services/notes/post_process_service_spec.rb
spec/services/notes/post_process_service_spec.rb
+1
-0
spec/services/task_service_spec.rb
spec/services/task_service_spec.rb
+39
-4
No files found.
app/services/notes/post_process_service.rb
View file @
49cd1965
module
Notes
class
PostProcessService
attr_accessor
:note
def
initialize
(
note
)
...
...
@@ -14,6 +13,8 @@ module Notes
@note
.
create_cross_references!
execute_note_hooks
end
TaskService
.
new
.
new_note
(
note
)
end
def
hook_data
...
...
@@ -25,6 +26,5 @@ module Notes
@note
.
project
.
execute_hooks
(
note_data
,
:note_hooks
)
@note
.
project
.
execute_services
(
note_data
,
:note_hooks
)
end
end
end
app/services/task_service.rb
View file @
49cd1965
...
...
@@ -43,6 +43,17 @@ class TaskService
pending_tasks
.
update_all
(
state: :done
)
end
# When create a note we should:
#
# * mark all pending tasks related to the noteable for the note author as done
#
def
new_note
(
note
)
# Skip system notes, like status changes and cross-references
unless
note
.
system
mark_as_done
(
note
.
noteable
,
note
.
author
)
end
end
private
def
create_task
(
project
,
target
,
author
,
user
,
action
)
...
...
spec/services/notes/post_process_service_spec.rb
View file @
49cd1965
...
...
@@ -20,6 +20,7 @@ describe Notes::PostProcessService, services: true do
it
do
expect
(
project
).
to
receive
(
:execute_hooks
)
expect
(
project
).
to
receive
(
:execute_services
)
expect_any_instance_of
(
TaskService
).
to
receive
(
:new_note
).
with
(
@note
)
Notes
::
PostProcessService
.
new
(
@note
).
execute
end
end
...
...
spec/services/task_service_spec.rb
View file @
49cd1965
...
...
@@ -43,8 +43,8 @@ describe TaskService, services: true do
it
'marks related pending tasks to the target for the user as done'
do
service
.
close_issue
(
assigned_issue
,
john_doe
)
expect
(
first_pending_task
.
reload
.
done?
).
to
eq
tru
e
expect
(
second_pending_task
.
reload
.
done?
).
to
eq
tru
e
expect
(
first_pending_task
.
reload
).
to
be_don
e
expect
(
second_pending_task
.
reload
).
to
be_don
e
end
end
...
...
@@ -75,8 +75,43 @@ describe TaskService, services: true do
it
'marks related pending tasks to the target for the user as done'
do
service
.
mark_as_done
(
assigned_issue
,
john_doe
)
expect
(
first_pending_task
.
reload
.
done?
).
to
eq
true
expect
(
second_pending_task
.
reload
.
done?
).
to
eq
true
expect
(
first_pending_task
.
reload
).
to
be_done
expect
(
second_pending_task
.
reload
).
to
be_done
end
end
describe
'#new_note'
do
let!
(
:first_pending_task
)
do
create
(
:pending_assigned_task
,
user:
john_doe
,
project:
project
,
target:
assigned_issue
,
author:
author
)
end
let!
(
:second_pending_task
)
do
create
(
:pending_assigned_task
,
user:
john_doe
,
project:
project
,
target:
assigned_issue
,
author:
author
)
end
let
(
:note
)
{
create
(
:note
,
project:
project
,
noteable:
assigned_issue
,
author:
john_doe
)
}
let
(
:award_note
)
{
create
(
:note
,
:award
,
project:
project
,
noteable:
assigned_issue
,
author:
john_doe
,
note:
'thumbsup'
)
}
let
(
:system_note
)
{
create
(
:system_note
,
project:
project
,
noteable:
assigned_issue
)
}
it
'mark related pending tasks to the noteable for the note author as done'
do
service
.
new_note
(
note
)
expect
(
first_pending_task
.
reload
).
to
be_done
expect
(
second_pending_task
.
reload
).
to
be_done
end
it
'mark related pending tasks to the noteable for the award note author as done'
do
service
.
new_note
(
award_note
)
expect
(
first_pending_task
.
reload
).
to
be_done
expect
(
second_pending_task
.
reload
).
to
be_done
end
it
'does not mark related pending tasks it is a system note'
do
service
.
new_note
(
system_note
)
expect
(
first_pending_task
.
reload
).
to
be_pending
expect
(
second_pending_task
.
reload
).
to
be_pending
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