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
1
Merge Requests
1
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
nexedi
gitlab-ce
Commits
b83f9a55
Commit
b83f9a55
authored
Jun 17, 2016
by
Douglas Barbosa Alexandre
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix error when editing an issuable with a task list
parent
1051f0c5
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
40 additions
and
19 deletions
+40
-19
app/services/todo_service.rb
app/services/todo_service.rb
+6
-1
spec/services/todo_service_spec.rb
spec/services/todo_service_spec.rb
+34
-18
No files found.
app/services/todo_service.rb
View file @
b83f9a55
...
@@ -161,11 +161,16 @@ class TodoService
...
@@ -161,11 +161,16 @@ class TodoService
def
update_issuable
(
issuable
,
author
)
def
update_issuable
(
issuable
,
author
)
# Skip toggling a task list item in a description
# Skip toggling a task list item in a description
return
if
issuable
.
tasks?
&&
issuable
.
updated_tasks
.
any?
return
if
toggling_tasks?
(
issuable
)
create_mention_todos
(
issuable
.
project
,
issuable
,
author
)
create_mention_todos
(
issuable
.
project
,
issuable
,
author
)
end
end
def
toggling_tasks?
(
issuable
)
issuable
.
previous_changes
.
include?
(
'description'
)
&&
issuable
.
tasks?
&&
issuable
.
updated_tasks
.
any?
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 @
b83f9a55
...
@@ -108,17 +108,25 @@ describe TodoService, services: true do
...
@@ -108,17 +108,25 @@ describe TodoService, services: true do
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
context
'issues with a task list'
do
issue
.
update
(
description:
"- [x] Task 1
\n
- [X] Task 2
#{
mentions
}
"
)
it
'does not create todo 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
service
.
update_issue
(
issue
,
author
)
it
'does not raise an error when description not change'
do
issue
.
update
(
title:
'Sample'
)
should_not_create_todo
(
user:
admin
,
target:
issue
,
action:
Todo
::
MENTIONED
)
expect
{
service
.
update_issue
(
issue
,
author
)
}.
not_to
raise_error
should_not_create_todo
(
user:
assignee
,
target:
issue
,
action:
Todo
::
MENTIONED
)
end
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
end
...
@@ -285,17 +293,25 @@ describe TodoService, services: true do
...
@@ -285,17 +293,25 @@ 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
context
'with a task list'
do
mr_assigned
.
update
(
description:
"- [x] Task 1
\n
- [X] Task 2
#{
mentions
}
"
)
it
'does not create todo 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
)
service
.
update_merge_request
(
mr_assigned
,
author
)
should_not_create_todo
(
user:
admin
,
target:
mr_assigned
,
action:
Todo
::
MENTIONED
)
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:
assignee
,
target:
mr_assigned
,
action:
Todo
::
MENTIONED
)
should_not_create_todo
(
user:
author
,
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:
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:
member
,
target:
mr_assigned
,
action:
Todo
::
MENTIONED
)
should_not_create_todo
(
user:
non_member
,
target:
mr_assigned
,
action:
Todo
::
MENTIONED
)
should_not_create_todo
(
user:
non_member
,
target:
mr_assigned
,
action:
Todo
::
MENTIONED
)
end
it
'does not raise an error when description not change'
do
mr_assigned
.
update
(
title:
'Sample'
)
expect
{
service
.
update_merge_request
(
mr_assigned
,
author
)
}.
not_to
raise_error
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