Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
李少辉-开发者
gitlab-foss
提交
9d6ffcfa
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,发现更多精彩内容 >>
提交
9d6ffcfa
编写于
3月 29, 2015
作者:
D
Dmitriy Zaporozhets
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Refactor star btn logic for non-logged in user and fix tests
上级
405f91d2
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
26 addition
and
17 deletion
+26
-17
app/helpers/projects_helper.rb
app/helpers/projects_helper.rb
+10
-12
app/views/projects/_home_panel.html.haml
app/views/projects/_home_panel.html.haml
+9
-2
features/project/star.feature
features/project/star.feature
+1
-1
features/steps/project/star.rb
features/steps/project/star.rb
+6
-2
未找到文件。
app/helpers/projects_helper.rb
浏览文件 @
9d6ffcfa
...
@@ -80,17 +80,17 @@ module ProjectsHelper
...
@@ -80,17 +80,17 @@ module ProjectsHelper
@project
.
milestones
.
active
.
order
(
"due_date, title ASC"
)
@project
.
milestones
.
active
.
order
(
"due_date, title ASC"
)
end
end
def
link_to_toggle_star
(
title
,
starred
,
signed_in
)
def
link_to_toggle_star
(
title
,
starred
)
cls
=
'star-btn btn btn-sm btn-default'
cls
=
'star-btn btn btn-sm btn-default'
cls
<<
' disabled'
unless
signed_in
toggle_
html
=
content_tag
(
'span'
,
class:
'toggle'
)
do
toggle_
text
=
toggle_text
=
if
starred
if
starred
' Unstar'
' Unstar'
else
else
' Star'
' Star'
end
end
toggle_html
=
content_tag
(
'span'
,
class:
'toggle'
)
do
icon
(
'star'
)
+
toggle_text
icon
(
'star'
)
+
toggle_text
end
end
...
@@ -106,12 +106,10 @@ module ProjectsHelper
...
@@ -106,12 +106,10 @@ module ProjectsHelper
data:
{
type:
'json'
}
data:
{
type:
'json'
}
}
}
path
=
toggle_star_namespace_project_path
(
@project
.
namespace
,
@project
)
content_tag
'span'
,
class:
starred
?
'turn-on'
:
'turn-off'
do
content_tag
'span'
,
class:
starred
?
'turn-on'
:
'turn-off'
do
link_to
(
link_to
(
path
,
link_opts
)
do
toggle_star_namespace_project_path
(
@project
.
namespace
,
@project
),
link_opts
)
do
toggle_html
+
' '
+
count_html
toggle_html
+
' '
+
count_html
end
end
end
end
...
...
app/views/projects/_home_panel.html.haml
浏览文件 @
9d6ffcfa
...
@@ -17,8 +17,15 @@
...
@@ -17,8 +17,15 @@
.project-repo-buttons
.project-repo-buttons
.inline.star.js-toggler-container
{
class:
@show_star
?
'on'
:
''
}
.inline.star.js-toggler-container
{
class:
@show_star
?
'on'
:
''
}
-
if
current_user
-
if
current_user
=
link_to_toggle_star
(
'Star this project.'
,
false
,
true
)
=
link_to_toggle_star
(
'Star this project.'
,
false
)
=
link_to_toggle_star
(
'Unstar this project.'
,
true
,
true
)
=
link_to_toggle_star
(
'Unstar this project.'
,
true
)
-
else
=
link_to
new_user_session_path
,
class:
'btn star-btn has_tooltip'
,
title:
'You must sign in to star a project'
do
%span
=
icon
(
'star'
)
Star
%span
.count
=
@project
.
star_count
-
unless
@project
.
empty_repo?
-
unless
@project
.
empty_repo?
-
if
current_user
&&
can?
(
current_user
,
:fork_project
,
@project
)
&&
@project
.
namespace
!=
current_user
.
namespace
-
if
current_user
&&
can?
(
current_user
,
:fork_project
,
@project
)
&&
@project
.
namespace
!=
current_user
.
namespace
.inline.fork-buttons.prepend-left-10
.inline.fork-buttons.prepend-left-10
...
...
features/project/star.feature
浏览文件 @
9d6ffcfa
...
@@ -13,7 +13,7 @@ Feature: Project Star
...
@@ -13,7 +13,7 @@ Feature: Project Star
Given
public project
"Community"
Given
public project
"Community"
And
I visit project
"Community"
page
And
I visit project
"Community"
page
When
I click on the star toggle button
When
I click on the star toggle button
Then
The project has 0 stars
Then
I redirected to sign in page
@javascript
@javascript
Scenario
:
Signed in users can toggle star
Scenario
:
Signed in users can toggle star
...
...
features/steps/project/star.rb
浏览文件 @
9d6ffcfa
...
@@ -22,12 +22,16 @@ class Spinach::Features::ProjectStar < Spinach::FeatureSteps
...
@@ -22,12 +22,16 @@ class Spinach::Features::ProjectStar < Spinach::FeatureSteps
# Requires @javascript
# Requires @javascript
step
"I click on the star toggle button"
do
step
"I click on the star toggle button"
do
find
(
".star .toggle"
,
visible:
true
).
click
find
(
".star-btn"
,
visible:
true
).
click
end
step
'I redirected to sign in page'
do
current_path
.
should
==
new_user_session_path
end
end
protected
protected
def
has_n_stars
(
n
)
def
has_n_stars
(
n
)
expect
(
page
).
to
have_css
(
".star
.count"
,
text:
/^
#{
n
}
$/
,
visible:
true
)
expect
(
page
).
to
have_css
(
".star
-btn .count"
,
text:
n
,
visible:
true
)
end
end
end
end
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录