Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
李少辉-开发者
gitlab-foss
提交
79bd1b87
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,发现更多精彩内容 >>
提交
79bd1b87
编写于
1月 29, 2019
作者:
B
Brett Walker
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Enable fast task lists for merge requests
Allow single tasks to be updated quickly
上级
ca154f0f
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
98 addition
and
73 deletion
+98
-73
app/controllers/projects/merge_requests/application_controller.rb
...rollers/projects/merge_requests/application_controller.rb
+2
-1
app/services/merge_requests/update_service.rb
app/services/merge_requests/update_service.rb
+6
-1
app/services/task_list_toggle_service.rb
app/services/task_list_toggle_service.rb
+2
-1
spec/services/issues/update_service_spec.rb
spec/services/issues/update_service_spec.rb
+2
-70
spec/services/merge_requests/update_service_spec.rb
spec/services/merge_requests/update_service_spec.rb
+2
-0
spec/services/task_list_toggle_service_spec.rb
spec/services/task_list_toggle_service_spec.rb
+11
-0
spec/support/shared_examples/issuable_shared_examples.rb
spec/support/shared_examples/issuable_shared_examples.rb
+73
-0
未找到文件。
app/controllers/projects/merge_requests/application_controller.rb
浏览文件 @
79bd1b87
...
...
@@ -34,7 +34,8 @@ class Projects::MergeRequests::ApplicationController < Projects::ApplicationCont
:task_num
,
:title
,
:discussion_locked
,
label_ids:
[]
label_ids:
[],
update_task:
[
:index
,
:checked
,
:line_number
,
:line_source
]
]
end
...
...
app/services/merge_requests/update_service.rb
浏览文件 @
79bd1b87
...
...
@@ -21,7 +21,7 @@ module MergeRequests
end
handle_wip_event
(
merge_request
)
update
(
merge_request
)
update
_task_event
(
merge_request
)
||
update
(
merge_request
)
end
# rubocop:disable Metrics/AbcSize
...
...
@@ -83,6 +83,11 @@ module MergeRequests
end
# rubocop:enable Metrics/AbcSize
def
handle_task_changes
(
merge_request
)
todo_service
.
mark_pending_todos_as_done
(
merge_request
,
current_user
)
todo_service
.
update_merge_request
(
merge_request
,
current_user
)
end
def
merge_from_quick_action
(
merge_request
)
last_diff_sha
=
params
.
delete
(
:merge
)
return
unless
merge_request
.
mergeable_with_quick_action?
(
current_user
,
last_diff_sha:
last_diff_sha
)
...
...
app/services/task_list_toggle_service.rb
浏览文件 @
79bd1b87
...
...
@@ -32,7 +32,8 @@ class TaskListToggleService
source_line_index
=
line_number
-
1
markdown_task
=
source_lines
[
source_line_index
]
return
unless
markdown_task
==
line_source
# The source in the DB could be using either \n or \r\n line endings
return
unless
markdown_task
==
line_source
||
markdown_task
==
line_source
+
"
\r
"
return
unless
source_checkbox
=
Taskable
::
ITEM_PATTERN
.
match
(
markdown_task
)
currently_checked
=
TaskList
::
Item
.
new
(
source_checkbox
[
1
]).
complete?
...
...
spec/services/issues/update_service_spec.rb
浏览文件 @
79bd1b87
...
...
@@ -471,6 +471,8 @@ describe Issues::UpdateService, :mailer do
it
{
expect
(
issue
.
tasks?
).
to
eq
(
true
)
}
it_behaves_like
'updating a single task'
context
'when tasks are marked as completed'
do
before
do
update_issue
(
description:
"- [x] Task 1
\n
- [X] Task 2"
)
...
...
@@ -543,76 +545,6 @@ describe Issues::UpdateService, :mailer do
end
end
context
'when updating a single task'
do
before
do
update_issue
(
description:
"- [ ] Task 1
\n
- [ ] Task 2"
)
end
it
{
expect
(
issue
.
tasks?
).
to
eq
(
true
)
}
context
'when a task is marked as completed'
do
before
do
update_issue
(
update_task:
{
index:
1
,
checked:
true
,
line_source:
'- [ ] Task 1'
,
line_number:
1
})
end
it
'creates system note about task status change'
do
note1
=
find_note
(
'marked the task **Task 1** as completed'
)
expect
(
note1
).
not_to
be_nil
description_notes
=
find_notes
(
'description'
)
expect
(
description_notes
.
length
).
to
eq
(
1
)
end
end
context
'when a task is marked as incomplete'
do
before
do
update_issue
(
description:
"- [x] Task 1
\n
- [X] Task 2"
)
update_issue
(
update_task:
{
index:
2
,
checked:
false
,
line_source:
'- [X] Task 2'
,
line_number:
2
})
end
it
'creates system note about task status change'
do
note1
=
find_note
(
'marked the task **Task 2** as incomplete'
)
expect
(
note1
).
not_to
be_nil
description_notes
=
find_notes
(
'description'
)
expect
(
description_notes
.
length
).
to
eq
(
1
)
end
end
context
'when the task position has been modified'
do
before
do
update_issue
(
description:
"- [ ] Task 1
\n
- [ ] Task 3
\n
- [ ] Task 2"
)
end
it
'raises an exception'
do
expect
(
Note
.
count
).
to
eq
(
2
)
expect
do
update_issue
(
update_task:
{
index:
2
,
checked:
true
,
line_source:
'- [ ] Task 2'
,
line_number:
2
})
end
.
to
raise_error
(
ActiveRecord
::
StaleObjectError
)
expect
(
Note
.
count
).
to
eq
(
2
)
end
end
context
'when the content changes but not task line number'
do
before
do
update_issue
(
description:
"Paragraph
\n\n
- [ ] Task 1
\n
- [x] Task 2"
)
update_issue
(
description:
"Paragraph with more words
\n\n
- [ ] Task 1
\n
- [x] Task 2"
)
update_issue
(
update_task:
{
index:
2
,
checked:
false
,
line_source:
'- [x] Task 2'
,
line_number:
4
})
end
it
'creates system note about task status change'
do
note1
=
find_note
(
'marked the task **Task 2** as incomplete'
)
expect
(
note1
).
not_to
be_nil
description_notes
=
find_notes
(
'description'
)
expect
(
description_notes
.
length
).
to
eq
(
2
)
end
end
end
context
'updating labels'
do
let
(
:label3
)
{
create
(
:label
,
project:
project
)
}
let
(
:result
)
{
described_class
.
new
(
project
,
user
,
params
).
execute
(
issue
).
reload
}
...
...
spec/services/merge_requests/update_service_spec.rb
浏览文件 @
79bd1b87
...
...
@@ -466,6 +466,8 @@ describe MergeRequests::UpdateService, :mailer do
it
{
expect
(
@merge_request
.
tasks?
).
to
eq
(
true
)
}
it_behaves_like
'updating a single task'
context
'when tasks are marked as completed'
do
before
do
update_merge_request
({
description:
"- [x] Task 1
\n
- [X] Task 2"
})
...
...
spec/services/task_list_toggle_service_spec.rb
浏览文件 @
79bd1b87
...
...
@@ -67,6 +67,17 @@ describe TaskListToggleService do
expect
(
toggler
.
execute
).
to
be_falsey
end
it
'tolerates \r\n line endings'
do
rn_markdown
=
markdown
.
gsub
(
"
\n
"
,
"
\r\n
"
)
toggler
=
described_class
.
new
(
rn_markdown
,
markdown_html
,
toggle_as_checked:
true
,
line_source:
'* [ ] Task 1'
,
line_number:
1
)
expect
(
toggler
.
execute
).
to
be_truthy
expect
(
toggler
.
updated_markdown
.
lines
[
0
]).
to
eq
"* [x] Task 1
\r\n
"
expect
(
toggler
.
updated_markdown_html
).
to
include
(
'disabled checked> Task 1'
)
end
it
'returns false if markdown is nil'
do
toggler
=
described_class
.
new
(
nil
,
markdown_html
,
toggle_as_checked:
false
,
...
...
spec/support/shared_examples/issuable_shared_examples.rb
浏览文件 @
79bd1b87
...
...
@@ -36,3 +36,76 @@ shared_examples 'system notes for milestones' do
end
end
end
shared_examples
'updating a single task'
do
def
update_issuable
(
opts
)
issuable
=
try
(
:issue
)
||
try
(
:merge_request
)
described_class
.
new
(
project
,
user
,
opts
).
execute
(
issuable
)
end
before
do
update_issuable
(
description:
"- [ ] Task 1
\n
- [ ] Task 2"
)
end
context
'when a task is marked as completed'
do
before
do
update_issuable
(
update_task:
{
index:
1
,
checked:
true
,
line_source:
'- [ ] Task 1'
,
line_number:
1
})
end
it
'creates system note about task status change'
do
note1
=
find_note
(
'marked the task **Task 1** as completed'
)
expect
(
note1
).
not_to
be_nil
description_notes
=
find_notes
(
'description'
)
expect
(
description_notes
.
length
).
to
eq
(
1
)
end
end
context
'when a task is marked as incomplete'
do
before
do
update_issuable
(
description:
"- [x] Task 1
\n
- [X] Task 2"
)
update_issuable
(
update_task:
{
index:
2
,
checked:
false
,
line_source:
'- [X] Task 2'
,
line_number:
2
})
end
it
'creates system note about task status change'
do
note1
=
find_note
(
'marked the task **Task 2** as incomplete'
)
expect
(
note1
).
not_to
be_nil
description_notes
=
find_notes
(
'description'
)
expect
(
description_notes
.
length
).
to
eq
(
1
)
end
end
context
'when the task position has been modified'
do
before
do
update_issuable
(
description:
"- [ ] Task 1
\n
- [ ] Task 3
\n
- [ ] Task 2"
)
end
it
'raises an exception'
do
expect
(
Note
.
count
).
to
eq
(
2
)
expect
do
update_issuable
(
update_task:
{
index:
2
,
checked:
true
,
line_source:
'- [ ] Task 2'
,
line_number:
2
})
end
.
to
raise_error
(
ActiveRecord
::
StaleObjectError
)
expect
(
Note
.
count
).
to
eq
(
2
)
end
end
context
'when the content changes but not task line number'
do
before
do
update_issuable
(
description:
"Paragraph
\n\n
- [ ] Task 1
\n
- [x] Task 2"
)
update_issuable
(
description:
"Paragraph with more words
\n\n
- [ ] Task 1
\n
- [x] Task 2"
)
update_issuable
(
update_task:
{
index:
2
,
checked:
false
,
line_source:
'- [x] Task 2'
,
line_number:
4
})
end
it
'creates system note about task status change'
do
note1
=
find_note
(
'marked the task **Task 2** as incomplete'
)
expect
(
note1
).
not_to
be_nil
description_notes
=
find_notes
(
'description'
)
expect
(
description_notes
.
length
).
to
eq
(
2
)
end
end
end
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录