Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
李少辉-开发者
gitlab-foss
提交
7629dc99
G
gitlab-foss
项目概览
李少辉-开发者
/
gitlab-foss
通知
15
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
G
gitlab-foss
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
7629dc99
编写于
8月 12, 2016
作者:
P
Paco Guzman
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add specs to ensure a successful return
on the UI when mark as done a already done todo.
上级
6fb46b60
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
44 addition
and
1 deletion
+44
-1
app/services/todo_service.rb
app/services/todo_service.rb
+2
-1
spec/features/todos/todos_spec.rb
spec/features/todos/todos_spec.rb
+21
-0
spec/services/todo_service_spec.rb
spec/services/todo_service_spec.rb
+21
-0
未找到文件。
app/services/todo_service.rb
浏览文件 @
7629dc99
...
...
@@ -148,7 +148,8 @@ class TodoService
def
mark_todos_as_done_by_ids
(
ids
,
current_user
)
todos
=
current_user
.
todos
.
where
(
id:
ids
)
marked_todos
=
todos
.
update_all
(
state: :done
)
# Only return those that are not really on that state
marked_todos
=
todos
.
where
.
not
(
state: :done
).
update_all
(
state: :done
)
current_user
.
update_todos_count_cache
marked_todos
end
...
...
spec/features/todos/todos_spec.rb
浏览文件 @
7629dc99
...
...
@@ -41,6 +41,27 @@ describe 'Dashboard Todos', feature: true do
expect
(
page
).
to
have_content
(
"You're all done!"
)
end
end
context
'todo is stale on the page'
do
before
do
todos
=
TodosFinder
.
new
(
user
,
state: :pending
).
execute
TodoService
.
new
.
mark_todos_as_done
(
todos
,
user
)
end
describe
'deleting the todo'
do
before
do
first
(
'.done-todo'
).
click
end
it
'is removed from the list'
do
expect
(
page
).
not_to
have_selector
(
'.todos-list .todo'
)
end
it
'shows "All done" message'
do
expect
(
page
).
to
have_content
(
"You're all done!"
)
end
end
end
end
context
'User has Todos with labels spanning multiple projects'
do
...
...
spec/services/todo_service_spec.rb
浏览文件 @
7629dc99
...
...
@@ -496,6 +496,7 @@ describe TodoService, services: true do
describe
'#mark_todos_as_done'
do
let
(
:issue
)
{
create
(
:issue
,
project:
project
,
author:
author
,
assignee:
john_doe
)
}
let
(
:another_issue
)
{
create
(
:issue
,
project:
project
,
author:
author
,
assignee:
john_doe
)
}
it
'marks a relation of todos as done'
do
create
(
:todo
,
:mentioned
,
user:
john_doe
,
target:
issue
,
project:
project
)
...
...
@@ -518,6 +519,26 @@ describe TodoService, services: true do
expect
(
TodoService
.
new
.
mark_todos_as_done
([
todo
],
john_doe
)).
to
eq
(
1
)
end
context
'when some of the todos are done already'
do
before
do
create
(
:todo
,
:mentioned
,
user:
john_doe
,
target:
issue
,
project:
project
)
create
(
:todo
,
:mentioned
,
user:
john_doe
,
target:
another_issue
,
project:
project
)
end
it
'returns the number of those still pending'
do
TodoService
.
new
.
mark_pending_todos_as_done
(
issue
,
john_doe
)
expect
(
TodoService
.
new
.
mark_todos_as_done
(
Todo
.
all
,
john_doe
)).
to
eq
(
1
)
end
it
'returns 0 if all are done'
do
TodoService
.
new
.
mark_pending_todos_as_done
(
issue
,
john_doe
)
TodoService
.
new
.
mark_pending_todos_as_done
(
another_issue
,
john_doe
)
expect
(
TodoService
.
new
.
mark_todos_as_done
(
Todo
.
all
,
john_doe
)).
to
eq
(
0
)
end
end
it
'caches the number of todos of a user'
,
:caching
do
create
(
:todo
,
:mentioned
,
user:
john_doe
,
target:
issue
,
project:
project
)
todo
=
create
(
:todo
,
:mentioned
,
user:
john_doe
,
target:
issue
,
project:
project
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录