Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
李少辉-开发者
gitlab-foss
提交
349e3622
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,发现更多精彩内容 >>
提交
349e3622
编写于
11月 15, 2017
作者:
J
Jose Ivan Vargas
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Added ssh_button helper specs and addressed ruby code observations
上级
2e2f0675
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
67 addition
and
36 deletion
+67
-36
app/assets/stylesheets/pages/projects.scss
app/assets/stylesheets/pages/projects.scss
+4
-0
app/helpers/button_helper.rb
app/helpers/button_helper.rb
+22
-22
spec/helpers/button_helper_spec.rb
spec/helpers/button_helper_spec.rb
+41
-14
未找到文件。
app/assets/stylesheets/pages/projects.scss
浏览文件 @
349e3622
...
...
@@ -409,6 +409,10 @@
.clone-options-dropdown
{
min-width
:
240px
;
.dropdown-menu-inner-content
{
min-width
:
320px
;
}
}
}
...
...
app/helpers/button_helper.rb
浏览文件 @
349e3622
...
...
@@ -58,34 +58,34 @@ module ButtonHelper
def
http_clone_button
(
project
,
append_link:
true
)
protocol
=
gitlab_config
.
protocol
.
upcase
dropdown_description
=
http_dropdown_description
(
protocol
)
append_url
=
project
.
http_url_to_repo
if
append_link
protocol_description
=
if
current_user
.
try
(
:require_password_creation?
)
_
(
"Set a password on your account to pull or push via %{protocol}."
)
%
{
protocol:
protocol
}
else
_
(
"Create a personal access token on your account to pull or push via %{protocol}."
)
%
{
protocol:
protocol
}
end
protocol_element_output
=
content_tag
(
:strong
,
protocol
,
class:
'dropdown-menu-inner-title'
)
dropdown_item_with_description
(
protocol
,
dropdown_description
,
href:
append_url
)
end
if
current_user
.
try
(
:require_password_creation?
)
||
current_user
.
try
(
:require_personal_access_token_creation_for_git_auth?
)
protocol_element_output
<<
content_tag
(
:span
,
protocol_description
,
class:
'dropdown-menu-inner-content'
)
def
http_dropdown_description
(
protocol
)
if
current_user
.
try
(
:require_password_creation_for_git?
)
_
(
"Set a password on your account to pull or push via %{protocol}."
)
%
{
protocol:
protocol
}
else
_
(
"Create a personal access token on your account to pull or push via %{protocol}."
)
%
{
protocol:
protocol
}
end
content_tag
(
append_link
?
:a
:
:span
),
protocol_element_output
,
class:
'http-selector'
,
href:
(
project
.
http_url_to_repo
if
append_link
)
end
def
ssh_clone_button
(
project
,
append_link:
true
)
ssh_description
=
_
(
"You won't be able to pull or push project code via SSH until you add an SSH key to your profile"
)
ssh_element_output
=
content_tag
(
:strong
,
'SSH'
,
class:
'dropdown-menu-inner-title'
)
ssh_element_output
<<
content_tag
(
:span
,
ssh_description
,
class:
'dropdown-menu-inner-content'
)
if
current_user
.
try
(
:require_ssh_key?
)
dropdown_description
=
_
(
"You won't be able to pull or push project code via SSH until you add an SSH key to your profile"
)
if
current_user
.
try
(
:require_ssh_key?
)
append_url
=
project
.
ssh_url_to_repo
if
append_link
dropdown_item_with_description
(
'SSH'
,
dropdown_description
,
href:
append_url
)
end
def
dropdown_item_with_description
(
title
,
description
,
href:
nil
)
button_content
=
content_tag
(
:strong
,
title
,
class:
'dropdown-menu-inner-title'
)
button_content
<<
content_tag
(
:span
,
description
,
class:
'dropdown-menu-inner-content'
)
if
description
content_tag
(
append_link
?
:a
:
:span
),
ssh_element_outpu
t
,
class:
'ssh-selector'
,
href:
(
project
.
ssh_url_to_repo
if
append_link
)
content_tag
(
href
?
:a
:
:span
),
button_conten
t
,
class:
"
#{
title
.
downcase
}
-selector"
,
href:
(
href
if
href
)
end
end
spec/helpers/button_helper_spec.rb
浏览文件 @
349e3622
...
...
@@ -27,9 +27,9 @@ describe ButtonHelper do
let
(
:user
)
{
create
(
:user
,
password_automatically_set:
true
)
}
it
'shows the password text on the dropdown'
do
expect
(
element
.
children
.
length
).
to
eq
(
2
)
expect
(
element
.
children
[
1
].
name
).
to
eq
(
'span'
)
expect
(
element
.
children
[
1
].
children
[
0
].
text
).
to
eq
(
'Set a password on your account to pull or push via HTTP.'
)
description
=
element
.
search
(
'.dropdown-menu-inner-content'
).
first
expect
(
description
.
inner_text
).
to
eq
'Set a password on your account to pull or push via HTTP.'
end
end
end
...
...
@@ -40,18 +40,10 @@ describe ButtonHelper do
end
context
'when user has no personal access tokens'
do
it
'has a personal access token tooltip '
do
expect
(
element
.
children
.
length
).
to
eq
(
2
)
expect
(
element
.
children
[
1
].
name
).
to
eq
(
'span'
)
expect
(
element
.
children
[
1
].
children
[
0
].
text
).
to
eq
(
'Create a personal access token on your account to pull or push via HTTP.'
)
end
end
context
'when user has a personal access token'
do
it
'shows no tooltip'
do
create
(
:personal_access_token
,
user:
user
)
it
'has a personal access token text on the dropdown description '
do
description
=
element
.
search
(
'.dropdown-menu-inner-content'
).
first
expect
(
element
.
attr
(
'class'
)).
not_to
include
(
has_tooltip_class
)
expect
(
description
.
inner_text
).
to
eq
'Create a personal access token on your account to pull or push via HTTP.'
end
end
end
...
...
@@ -65,6 +57,41 @@ describe ButtonHelper do
end
end
describe
'ssh_button'
do
let
(
:user
)
{
create
(
:user
)
}
let
(
:project
)
{
build_stubbed
(
:project
)
}
def
element
element
=
helper
.
ssh_clone_button
(
project
)
Nokogiri
::
HTML
::
DocumentFragment
.
parse
(
element
).
first_element_child
end
before
do
allow
(
helper
).
to
receive
(
:current_user
).
and_return
(
user
)
end
context
'without an ssh key on the user'
do
it
'shows a warning on the dropdown description'
do
description
=
element
.
search
(
'.dropdown-menu-inner-content'
).
first
expect
(
description
.
inner_text
).
to
eq
"You won't be able to pull or push project code via SSH until you add an SSH key to your profile"
end
end
context
'with an ssh key on the user'
do
before
do
create
(
:key
,
user:
user
)
end
it
'there is no warning on the dropdown description'
do
description
=
element
.
search
(
'.dropdown-menu-inner-content'
).
first
expect
(
description
).
to
eq
nil
end
end
end
describe
'clipboard_button'
do
let
(
:user
)
{
create
(
:user
)
}
let
(
:project
)
{
build_stubbed
(
:project
)
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录