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
Boxiang Sun
gitlab-ce
Commits
aadc5062
Commit
aadc5062
authored
Aug 11, 2016
by
Rémy Coutable
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
New TodoService#todo_exists? method
Signed-off-by:
Rémy Coutable
<
remy@rymai.me
>
parent
42e30a50
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
19 additions
and
3 deletions
+19
-3
app/services/slash_commands/interpret_service.rb
app/services/slash_commands/interpret_service.rb
+2
-2
app/services/todo_service.rb
app/services/todo_service.rb
+4
-0
spec/lib/gitlab/slash_commands/dsl_spec.rb
spec/lib/gitlab/slash_commands/dsl_spec.rb
+1
-1
spec/services/todo_service_spec.rb
spec/services/todo_service_spec.rb
+12
-0
No files found.
app/services/slash_commands/interpret_service.rb
View file @
aadc5062
...
@@ -140,7 +140,7 @@ module SlashCommands
...
@@ -140,7 +140,7 @@ module SlashCommands
condition
do
condition
do
noteable
.
persisted?
&&
noteable
.
persisted?
&&
current_user
&&
current_user
&&
!
Todo
sFinder
.
new
(
current_user
).
execute
.
exists?
(
target:
noteable
)
!
Todo
Service
.
new
.
todo_exist?
(
noteable
,
current_user
)
end
end
command
:todo
do
command
:todo
do
@updates
[
:todo_event
]
=
'add'
@updates
[
:todo_event
]
=
'add'
...
@@ -149,7 +149,7 @@ module SlashCommands
...
@@ -149,7 +149,7 @@ module SlashCommands
desc
'Mark todo as done'
desc
'Mark todo as done'
condition
do
condition
do
current_user
&&
current_user
&&
Todo
sFinder
.
new
(
current_user
).
execute
.
exists?
(
target:
noteable
)
Todo
Service
.
new
.
todo_exist?
(
noteable
,
current_user
)
end
end
command
:done
do
command
:done
do
@updates
[
:todo_event
]
=
'done'
@updates
[
:todo_event
]
=
'done'
...
...
app/services/todo_service.rb
View file @
aadc5062
...
@@ -154,6 +154,10 @@ class TodoService
...
@@ -154,6 +154,10 @@ class TodoService
create_todos
(
current_user
,
attributes
)
create_todos
(
current_user
,
attributes
)
end
end
def
todo_exist?
(
issuable
,
current_user
)
TodosFinder
.
new
(
current_user
).
execute
.
exists?
(
target:
issuable
)
end
private
private
def
create_todos
(
users
,
attributes
)
def
create_todos
(
users
,
attributes
)
...
...
spec/lib/gitlab/slash_commands/dsl_spec.rb
View file @
aadc5062
...
@@ -51,7 +51,7 @@ describe Gitlab::SlashCommands::Dsl do
...
@@ -51,7 +51,7 @@ describe Gitlab::SlashCommands::Dsl do
{
name: :one_arg
,
aliases:
[
:once
,
:first
],
description:
''
,
params:
[
'The first argument'
],
noop:
false
,
cond_block:
nil
},
{
name: :one_arg
,
aliases:
[
:once
,
:first
],
description:
''
,
params:
[
'The first argument'
],
noop:
false
,
cond_block:
nil
},
{
name: :two_args
,
aliases:
[],
description:
''
,
params:
[
'The first argument'
,
'The second argument'
],
noop:
false
,
cond_block:
nil
},
{
name: :two_args
,
aliases:
[],
description:
''
,
params:
[
'The first argument'
,
'The second argument'
],
noop:
false
,
cond_block:
nil
},
{
name: :cc
,
aliases:
[],
description:
''
,
params:
[],
noop:
true
,
cond_block:
nil
},
{
name: :cc
,
aliases:
[],
description:
''
,
params:
[],
noop:
true
,
cond_block:
nil
},
{
name: :wildcard
,
aliases:
[],
description:
''
,
params:
[],
noop:
false
,
cond_block:
nil
}
{
name: :wildcard
,
aliases:
[],
description:
''
,
params:
[],
noop:
false
,
cond_block:
nil
}
]
]
end
end
...
...
spec/services/todo_service_spec.rb
View file @
aadc5062
...
@@ -290,6 +290,18 @@ describe TodoService, services: true do
...
@@ -290,6 +290,18 @@ describe TodoService, services: true do
should_create_todo
(
user:
author
,
target:
unassigned_issue
,
action:
Todo
::
MARKED
)
should_create_todo
(
user:
author
,
target:
unassigned_issue
,
action:
Todo
::
MARKED
)
end
end
end
end
describe
'#todo_exists?'
do
it
'returns false when no todo exist for the given issuable'
do
expect
(
service
.
todo_exist?
(
unassigned_issue
,
author
)).
to
be_falsy
end
it
'returns true when a todo exist for the given issuable'
do
service
.
mark_todo
(
unassigned_issue
,
author
)
expect
(
service
.
todo_exist?
(
unassigned_issue
,
author
)).
to
be_truthy
end
end
end
end
describe
'Merge Requests'
do
describe
'Merge Requests'
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