Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Jérome Perrin
gitlab-ce
Commits
9d6ffcfa
Commit
9d6ffcfa
authored
Mar 29, 2015
by
Dmitriy Zaporozhets
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactor star btn logic for non-logged in user and fix tests
parent
405f91d2
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
26 additions
and
17 deletions
+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
No files found.
app/helpers/projects_helper.rb
View file @
9d6ffcfa
...
...
@@ -80,17 +80,17 @@ module ProjectsHelper
@project
.
milestones
.
active
.
order
(
"due_date, title ASC"
)
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
<<
' disabled'
unless
signed_in
toggle_
html
=
content_tag
(
'span'
,
class:
'toggle'
)
do
toggle_text
=
if
starred
toggle_
text
=
if
starred
' Unstar'
else
' Star'
end
toggle_html
=
content_tag
(
'span'
,
class:
'toggle'
)
do
icon
(
'star'
)
+
toggle_text
end
...
...
@@ -106,12 +106,10 @@ module ProjectsHelper
data:
{
type:
'json'
}
}
path
=
toggle_star_namespace_project_path
(
@project
.
namespace
,
@project
)
content_tag
'span'
,
class:
starred
?
'turn-on'
:
'turn-off'
do
link_to
(
toggle_star_namespace_project_path
(
@project
.
namespace
,
@project
),
link_opts
)
do
link_to
(
path
,
link_opts
)
do
toggle_html
+
' '
+
count_html
end
end
...
...
app/views/projects/_home_panel.html.haml
View file @
9d6ffcfa
...
...
@@ -17,8 +17,15 @@
.project-repo-buttons
.inline.star.js-toggler-container
{
class:
@show_star
?
'on'
:
''
}
-
if
current_user
=
link_to_toggle_star
(
'Star this project.'
,
false
,
true
)
=
link_to_toggle_star
(
'Unstar this project.'
,
true
,
true
)
=
link_to_toggle_star
(
'Star this project.'
,
false
)
=
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?
-
if
current_user
&&
can?
(
current_user
,
:fork_project
,
@project
)
&&
@project
.
namespace
!=
current_user
.
namespace
.inline.fork-buttons.prepend-left-10
...
...
features/project/star.feature
View file @
9d6ffcfa
...
...
@@ -13,7 +13,7 @@ Feature: Project Star
Given
public project
"Community"
And
I visit project
"Community"
page
When
I click on the star toggle button
Then
The project has 0 stars
Then
I redirected to sign in page
@javascript
Scenario
:
Signed in users can toggle star
...
...
features/steps/project/star.rb
View file @
9d6ffcfa
...
...
@@ -22,12 +22,16 @@ class Spinach::Features::ProjectStar < Spinach::FeatureSteps
# Requires @javascript
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
protected
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
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment