Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
李少辉-开发者
gitlab-foss
提交
5a286eb7
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 搜索 >>
提交
5a286eb7
编写于
10月 03, 2018
作者:
P
Paul Slaughter
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add signature badge to diffs/commit_item
**Notes:** - Also exposes commit.signature_html in diffs.json
上级
c375171b
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
54 addition
and
2 deletion
+54
-2
app/assets/javascripts/diffs/components/commit_item.vue
app/assets/javascripts/diffs/components/commit_item.vue
+4
-0
app/controllers/projects/merge_requests/diffs_controller.rb
app/controllers/projects/merge_requests/diffs_controller.rb
+7
-1
app/serializers/commit_entity.rb
app/serializers/commit_entity.rb
+10
-0
spec/javascripts/diffs/components/commit_item_spec.js
spec/javascripts/diffs/components/commit_item_spec.js
+18
-0
spec/serializers/commit_entity_spec.rb
spec/serializers/commit_entity_spec.rb
+15
-1
未找到文件。
app/assets/javascripts/diffs/components/commit_item.vue
浏览文件 @
5a286eb7
...
...
@@ -102,6 +102,10 @@ export default {
></pre>
</div>
<div
class=
"commit-actions flex-row d-none d-sm-flex"
>
<div
v-if=
"commit.signatureHtml"
v-html=
"commit.signatureHtml"
></div>
<div
class=
"commit-sha-group"
>
<div
class=
"label label-monospace"
...
...
app/controllers/projects/merge_requests/diffs_controller.rb
浏览文件 @
5a286eb7
...
...
@@ -25,7 +25,13 @@ class Projects::MergeRequests::DiffsController < Projects::MergeRequests::Applic
@diffs
.
write_cache
render
json:
DiffsSerializer
.
new
(
current_user:
current_user
,
project:
@merge_request
.
project
).
represent
(
@diffs
,
additional_attributes
)
request
=
{
current_user:
current_user
,
project:
@merge_request
.
project
,
render:
->
(
partial
,
locals
)
{
view_to_html_string
(
partial
,
locals
)
}
}
render
json:
DiffsSerializer
.
new
(
request
).
represent
(
@diffs
,
additional_attributes
)
end
def
define_diff_vars
...
...
app/serializers/commit_entity.rb
浏览文件 @
5a286eb7
...
...
@@ -25,4 +25,14 @@ class CommitEntity < API::Entities::Commit
expose
:title_html
,
if:
{
type: :full
}
do
|
commit
|
markdown_field
(
commit
,
:title
)
end
expose
:signature_html
,
if:
{
type: :full
}
do
|
commit
|
render
(
'projects/commit/_signature'
,
signature:
commit
.
signature
)
if
commit
.
has_signature?
end
def
render
(
*
args
)
return
unless
request
.
respond_to?
(
:render
)
&&
request
.
render
.
respond_to?
(
:call
)
request
.
render
.
call
(
*
args
)
end
end
spec/javascripts/diffs/components/commit_item_spec.js
浏览文件 @
5a286eb7
...
...
@@ -9,6 +9,7 @@ import getDiffWithCommit from '../mock_data/diff_with_commit';
const
TEST_AUTHOR_NAME
=
'
test
'
;
const
TEST_AUTHOR_EMAIL
=
'
test+test@gitlab.com
'
;
const
TEST_AUTHOR_GRAVATAR
=
`
${
TEST_HOST
}
/avatar/test?s=36`
;
const
TEST_SIGNATURE_HTML
=
'
<a>Legit commit</a>
'
;
const
getTitleElement
=
vm
=>
vm
.
$el
.
querySelector
(
'
.commit-row-message.item-title
'
);
const
getDescElement
=
vm
=>
vm
.
$el
.
querySelector
(
'
pre.commit-row-description
'
);
...
...
@@ -16,6 +17,7 @@ const getDescExpandElement = vm => vm.$el.querySelector('.commit-content .text-e
const
getShaElement
=
vm
=>
vm
.
$el
.
querySelector
(
'
.commit-sha-group
'
);
const
getAvatarElement
=
vm
=>
vm
.
$el
.
querySelector
(
'
.user-avatar-link
'
);
const
getCommitterElement
=
vm
=>
vm
.
$el
.
querySelector
(
'
.commiter
'
);
const
getCommitActionsElement
=
vm
=>
vm
.
$el
.
querySelector
(
'
.commit-actions
'
);
describe
(
'
diffs/components/commit_widget
'
,
()
=>
{
const
Component
=
Vue
.
extend
(
CommitItem
);
...
...
@@ -125,4 +127,20 @@ describe('diffs/components/commit_widget', () => {
expect
(
nameElement
).
toHaveText
(
TEST_AUTHOR_NAME
);
});
});
describe
(
'
with signature
'
,
()
=>
{
beforeEach
(
done
=>
{
vm
.
commit
.
signatureHtml
=
TEST_SIGNATURE_HTML
;
vm
.
$nextTick
()
.
then
(
done
)
.
catch
(
done
.
fail
);
});
it
(
'
renders signature html
'
,
()
=>
{
const
actionsElement
=
getCommitActionsElement
(
vm
);
expect
(
actionsElement
).
toContainHtml
(
TEST_SIGNATURE_HTML
);
});
});
});
spec/serializers/commit_entity_spec.rb
浏览文件 @
5a286eb7
require
'spec_helper'
describe
CommitEntity
do
SIGNATURE_HTML
=
'TEST'
.
freeze
let
(
:entity
)
do
described_class
.
new
(
commit
,
request:
request
)
end
let
(
:request
)
{
double
(
'request'
)
}
let
(
:project
)
{
create
(
:project
,
:repository
)
}
let
(
:commit
)
{
project
.
commit
}
...
...
@@ -12,7 +13,11 @@ describe CommitEntity do
subject
{
entity
.
as_json
}
before
do
render
=
double
(
'render'
)
allow
(
render
).
to
receive
(
:call
).
and_return
(
SIGNATURE_HTML
)
allow
(
request
).
to
receive
(
:project
).
and_return
(
project
)
allow
(
request
).
to
receive
(
:render
).
and_return
(
render
)
end
context
'when commit author is a user'
do
...
...
@@ -70,6 +75,15 @@ describe CommitEntity do
expect
(
subject
.
fetch
(
:description_html
)).
not_to
be_nil
expect
(
subject
.
fetch
(
:title_html
)).
not_to
be_nil
end
context
'when commit has signature'
do
let
(
:commit
)
{
project
.
commit
(
TestEnv
::
BRANCH_SHA
[
'signed-commits'
])
}
it
'exposes "signature_html"'
do
expect
(
request
.
render
).
to
receive
(
:call
)
expect
(
subject
.
fetch
(
:signature_html
)).
to
be
SIGNATURE_HTML
end
end
end
context
'when commit_url_params is set'
do
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录