Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
李少辉-开发者
gitlab-foss
提交
72009896
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,体验更适合开发者的 AI 搜索 >>
提交
72009896
编写于
2月 18, 2016
作者:
D
Douglas Barbosa Alexandre
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Refactoring task queue partials
上级
8673a70f
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
37 addition
and
79 deletion
+37
-79
app/helpers/tasks_helper.rb
app/helpers/tasks_helper.rb
+7
-5
app/models/task.rb
app/models/task.rb
+6
-6
app/views/dashboard/tasks/_common.html.haml
app/views/dashboard/tasks/_common.html.haml
+0
-17
app/views/dashboard/tasks/_note.html.haml
app/views/dashboard/tasks/_note.html.haml
+0
-26
app/views/dashboard/tasks/_task.html.haml
app/views/dashboard/tasks/_task.html.haml
+19
-6
spec/models/task_spec.rb
spec/models/task_spec.rb
+5
-19
未找到文件。
app/helpers/tasks_helper.rb
浏览文件 @
72009896
...
...
@@ -23,18 +23,20 @@ module TasksHelper
[
task
.
action_name
,
target
].
join
(
" "
)
end
def
task_
note
_link_html
(
task
)
link_to
task_
note_
target_path
(
task
)
do
def
task_
target
_link_html
(
task
)
link_to
task_target_path
(
task
)
do
"#
#{
task
.
target_iid
}
"
end
end
def
task_note_target_path
(
task
)
def
task_target_path
(
task
)
anchor
=
dom_id
(
task
.
note
)
if
task
.
note
.
present?
polymorphic_path
([
task
.
project
.
namespace
.
becomes
(
Namespace
),
task
.
project
,
task
.
target
],
anchor:
dom_id
(
task
.
note
)
)
task
.
project
,
task
.
target
],
anchor:
anchor
)
end
def
task_
note
(
text
,
options
=
{})
def
task_
body
(
text
,
options
=
{})
text
=
first_line_in_markdown
(
text
,
150
,
options
)
sanitize
(
text
,
tags:
%w(a img b pre code p span)
)
end
...
...
app/models/task.rb
浏览文件 @
72009896
...
...
@@ -50,12 +50,12 @@ class Task < ActiveRecord::Base
end
end
def
body
?
target
.
respond_to?
:title
end
def
note_text
note
.
try
(
:note
)
def
body
if
note
.
present?
note
.
note
else
target
.
title
end
end
def
target_iid
...
...
app/views/dashboard/tasks/_common.html.haml
已删除
100644 → 0
浏览文件 @
8673a70f
.task-title
%span
.author_name
=
link_to_author
task
%span
.task_label
{
class:
task
.
action_name
}
=
task_action_name
(
task
)
%strong
=
link_to
"#
#{
task
.
target_iid
}
"
,
[
task
.
project
.
namespace
.
becomes
(
Namespace
),
task
.
project
,
task
.
target
]
·
#{
time_ago_with_tooltip
(
task
.
created_at
)
}
-
if
task
.
pending?
.task-actions.pull-right
=
link_to
'Done'
,
[
:dashboard
,
task
],
method: :delete
,
class:
'btn'
-
if
task
.
body?
.task-body
.task-note
=
task
.
target
.
title
app/views/dashboard/tasks/_note.html.haml
已删除
100644 → 0
浏览文件 @
8673a70f
.task-title
%span
.author_name
=
link_to_author
task
%span
.task_label
{
class:
task
.
action_name
}
=
task_action_name
(
task
)
=
task_note_link_html
(
task
)
·
#{
time_ago_with_tooltip
(
task
.
created_at
)
}
-
if
task
.
pending?
.task-actions.pull-right
=
link_to
'Done'
,
[
:dashboard
,
task
],
method: :delete
,
class:
'btn'
.task-body
.task-note
.md
=
task_note
(
task
.
note_text
,
project:
task
.
project
)
-
note
=
task
.
note
-
if
note
.
attachment
.
url
-
if
note
.
attachment
.
image?
=
link_to
note
.
attachment
.
url
,
target:
'_blank'
do
=
image_tag
note
.
attachment
.
url
,
class:
'note-image-attach'
-
else
=
link_to
note
.
attachment
.
url
,
target:
"_blank"
,
class:
'note-file-attach'
do
%i
.fa.fa-paperclip
=
note
.
attachment_identifier
app/views/dashboard/tasks/_task.html.haml
浏览文件 @
72009896
%li
{
class:
"task task-#{task.done? ? 'done' : 'pending'}"
,
id:
dom_id
(
task
)
}
.task-item
{
class:
"#{task.body? ? 'task-block' : 'task-inline' }"
}
=
image_tag
avatar_icon
(
task
.
author_email
,
40
),
class:
"avatar s40"
,
alt
:''
.task-item
{
class:
'task-block'
}
=
image_tag
avatar_icon
(
task
.
author_email
,
40
),
class:
'avatar s40'
,
alt
:''
-
if
task
.
note
.
present?
=
render
'note'
,
task:
task
-
else
=
render
'common'
,
task:
task
.task-title
%span
.author_name
=
link_to_author
task
%span
.task_label
=
task_action_name
(
task
)
=
task_target_link_html
(
task
)
·
#{
time_ago_with_tooltip
(
task
.
created_at
)
}
-
if
task
.
pending?
.task-actions.pull-right
=
link_to
'Done'
,
[
:dashboard
,
task
],
method: :delete
,
class:
'btn'
.task-body
.task-note
.md
=
task_body
(
task
.
body
,
project:
task
.
project
)
spec/models/task_spec.rb
浏览文件 @
72009896
...
...
@@ -51,35 +51,21 @@ describe Task, models: true do
end
end
describe
'#body?'
do
let
(
:issue
)
{
build
(
:issue
)
}
describe
'#body'
do
before
do
subject
.
target
=
issue
end
it
'returns true when target respond to title'
do
expect
(
subject
.
body?
).
to
eq
true
subject
.
target
=
build
(
:issue
,
title:
'Bugfix'
)
end
it
'returns false when target does not respond to title'
do
allow
(
issue
).
to
receive
(
:respond_to?
).
with
(
:title
).
and_return
(
false
)
expect
(
subject
.
body?
).
to
eq
false
end
end
describe
'#note_text'
do
it
'returns nil when note is blank'
do
it
'returns target title when note is blank'
do
subject
.
note
=
nil
expect
(
subject
.
note_text
).
to
be_nil
expect
(
subject
.
body
).
to
eq
'Bugfix'
end
it
'returns note when note is present'
do
subject
.
note
=
build
(
:note
,
note:
'quick fix'
)
expect
(
subject
.
note_text
).
to
eq
'quick fix'
expect
(
subject
.
body
).
to
eq
'quick fix'
end
end
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录