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
Tatuya Kamada
gitlab-ce
Commits
aff3c699
Commit
aff3c699
authored
Jun 09, 2016
by
Douglas Barbosa Alexandre
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Toggling a task in a description with mentions doesn't creates a Todo
parent
ae126c55
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
37 additions
and
4 deletions
+37
-4
app/services/todo_service.rb
app/services/todo_service.rb
+9
-2
spec/services/todo_service_spec.rb
spec/services/todo_service_spec.rb
+28
-2
No files found.
app/services/todo_service.rb
View file @
aff3c699
...
@@ -20,7 +20,7 @@ class TodoService
...
@@ -20,7 +20,7 @@ class TodoService
# * mark all pending todos related to the issue for the current user as done
# * mark all pending todos related to the issue for the current user as done
#
#
def
update_issue
(
issue
,
current_user
)
def
update_issue
(
issue
,
current_user
)
create_mention_todos
(
issue
.
project
,
issue
,
current_user
)
update_issuable
(
issue
,
current_user
)
end
end
# When close an issue we should:
# When close an issue we should:
...
@@ -53,7 +53,7 @@ class TodoService
...
@@ -53,7 +53,7 @@ class TodoService
# * create a todo for each mentioned user on merge request
# * create a todo for each mentioned user on merge request
#
#
def
update_merge_request
(
merge_request
,
current_user
)
def
update_merge_request
(
merge_request
,
current_user
)
create_mention_todos
(
merge_request
.
project
,
merge_request
,
current_user
)
update_issuable
(
merge_request
,
current_user
)
end
end
# When close a merge request we should:
# When close a merge request we should:
...
@@ -153,6 +153,13 @@ class TodoService
...
@@ -153,6 +153,13 @@ class TodoService
create_mention_todos
(
issuable
.
project
,
issuable
,
author
)
create_mention_todos
(
issuable
.
project
,
issuable
,
author
)
end
end
def
update_issuable
(
issuable
,
author
)
# Skip toggling a task list item in a description
return
if
issuable
.
tasks?
&&
issuable
.
updated_tasks
.
any?
create_mention_todos
(
issuable
.
project
,
issuable
,
author
)
end
def
handle_note
(
note
,
author
)
def
handle_note
(
note
,
author
)
# Skip system notes, and notes on project snippet
# Skip system notes, and notes on project snippet
return
if
note
.
system?
||
note
.
for_snippet?
return
if
note
.
system?
||
note
.
for_snippet?
...
...
spec/services/todo_service_spec.rb
View file @
aff3c699
...
@@ -18,7 +18,7 @@ describe TodoService, services: true do
...
@@ -18,7 +18,7 @@ describe TodoService, services: true do
end
end
describe
'Issues'
do
describe
'Issues'
do
let
(
:issue
)
{
create
(
:issue
,
project:
project
,
assignee:
john_doe
,
author:
author
,
description:
mentions
)
}
let
(
:issue
)
{
create
(
:issue
,
project:
project
,
assignee:
john_doe
,
author:
author
,
description:
"- [ ] Task 1
\n
- [ ] Task 2
#{
mentions
}
"
)
}
let
(
:unassigned_issue
)
{
create
(
:issue
,
project:
project
,
assignee:
nil
)
}
let
(
:unassigned_issue
)
{
create
(
:issue
,
project:
project
,
assignee:
nil
)
}
let
(
:confidential_issue
)
{
create
(
:issue
,
:confidential
,
project:
project
,
author:
author
,
assignee:
assignee
,
description:
mentions
)
}
let
(
:confidential_issue
)
{
create
(
:issue
,
:confidential
,
project:
project
,
author:
author
,
assignee:
assignee
,
description:
mentions
)
}
...
@@ -101,6 +101,19 @@ describe TodoService, services: true do
...
@@ -101,6 +101,19 @@ describe TodoService, services: true do
should_create_todo
(
user:
admin
,
target:
confidential_issue
,
author:
john_doe
,
action:
Todo
::
MENTIONED
)
should_create_todo
(
user:
admin
,
target:
confidential_issue
,
author:
john_doe
,
action:
Todo
::
MENTIONED
)
should_not_create_todo
(
user:
john_doe
,
target:
confidential_issue
,
author:
john_doe
,
action:
Todo
::
MENTIONED
)
should_not_create_todo
(
user:
john_doe
,
target:
confidential_issue
,
author:
john_doe
,
action:
Todo
::
MENTIONED
)
end
end
it
'does not create todo when when tasks are marked as completed'
do
issue
.
update
(
description:
"- [x] Task 1
\n
- [X] Task 2
#{
mentions
}
"
)
service
.
update_issue
(
issue
,
author
)
should_not_create_todo
(
user:
admin
,
target:
issue
,
action:
Todo
::
MENTIONED
)
should_not_create_todo
(
user:
assignee
,
target:
issue
,
action:
Todo
::
MENTIONED
)
should_not_create_todo
(
user:
author
,
target:
issue
,
action:
Todo
::
MENTIONED
)
should_not_create_todo
(
user:
john_doe
,
target:
issue
,
action:
Todo
::
MENTIONED
)
should_not_create_todo
(
user:
member
,
target:
issue
,
action:
Todo
::
MENTIONED
)
should_not_create_todo
(
user:
non_member
,
target:
issue
,
action:
Todo
::
MENTIONED
)
end
end
end
describe
'#close_issue'
do
describe
'#close_issue'
do
...
@@ -210,7 +223,7 @@ describe TodoService, services: true do
...
@@ -210,7 +223,7 @@ describe TodoService, services: true do
end
end
describe
'Merge Requests'
do
describe
'Merge Requests'
do
let
(
:mr_assigned
)
{
create
(
:merge_request
,
source_project:
project
,
author:
author
,
assignee:
john_doe
,
description:
mentions
)
}
let
(
:mr_assigned
)
{
create
(
:merge_request
,
source_project:
project
,
author:
author
,
assignee:
john_doe
,
description:
"- [ ] Task 1
\n
- [ ] Task 2
#{
mentions
}
"
)
}
let
(
:mr_unassigned
)
{
create
(
:merge_request
,
source_project:
project
,
author:
author
,
assignee:
nil
)
}
let
(
:mr_unassigned
)
{
create
(
:merge_request
,
source_project:
project
,
author:
author
,
assignee:
nil
)
}
describe
'#new_merge_request'
do
describe
'#new_merge_request'
do
...
@@ -253,6 +266,19 @@ describe TodoService, services: true do
...
@@ -253,6 +266,19 @@ describe TodoService, services: true do
expect
{
service
.
update_merge_request
(
mr_assigned
,
author
)
}.
not_to
change
(
member
.
todos
,
:count
)
expect
{
service
.
update_merge_request
(
mr_assigned
,
author
)
}.
not_to
change
(
member
.
todos
,
:count
)
end
end
it
'does not create todo when when tasks are marked as completed'
do
mr_assigned
.
update
(
description:
"- [x] Task 1
\n
- [X] Task 2
#{
mentions
}
"
)
service
.
update_merge_request
(
mr_assigned
,
author
)
should_not_create_todo
(
user:
admin
,
target:
mr_assigned
,
action:
Todo
::
MENTIONED
)
should_not_create_todo
(
user:
assignee
,
target:
mr_assigned
,
action:
Todo
::
MENTIONED
)
should_not_create_todo
(
user:
author
,
target:
mr_assigned
,
action:
Todo
::
MENTIONED
)
should_not_create_todo
(
user:
john_doe
,
target:
mr_assigned
,
action:
Todo
::
MENTIONED
)
should_not_create_todo
(
user:
member
,
target:
mr_assigned
,
action:
Todo
::
MENTIONED
)
should_not_create_todo
(
user:
non_member
,
target:
mr_assigned
,
action:
Todo
::
MENTIONED
)
end
end
end
describe
'#close_merge_request'
do
describe
'#close_merge_request'
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