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
Kazuhiko Shiozaki
gitlab-ce
Commits
74d2085c
Commit
74d2085c
authored
Mar 09, 2014
by
Robert Speicher
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Sort tag names using VersionSorter
parent
a37c6794
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
40 additions
and
3 deletions
+40
-3
app/helpers/application_helper.rb
app/helpers/application_helper.rb
+2
-3
spec/helpers/application_helper_spec.rb
spec/helpers/application_helper_spec.rb
+38
-0
No files found.
app/helpers/application_helper.rb
View file @
74d2085c
...
...
@@ -94,11 +94,10 @@ module ApplicationHelper
options
=
[
[
"Branches"
,
repository
.
branch_names
],
[
"Tags"
,
repository
.
tag_names
]
[
"Tags"
,
VersionSorter
.
rsort
(
repository
.
tag_names
)
]
]
# If reference is commit id -
# we should add it to branch/tag selectbox
# If reference is commit id - we should add it to branch/tag selectbox
if
(
@ref
&&
!
options
.
flatten
.
include?
(
@ref
)
&&
@ref
=~
/^[0-9a-zA-Z]{6,52}$/
)
options
<<
[
"Commit"
,
[
@ref
]]
...
...
spec/helpers/application_helper_spec.rb
View file @
74d2085c
...
...
@@ -116,7 +116,45 @@ describe ApplicationHelper do
allow
(
self
).
to
receive
(
:request
).
and_return
(
double
(
:ssl?
=>
false
))
gravatar_icon
(
user_email
).
should
==
gravatar_icon
(
user_email
.
upcase
+
" "
)
end
end
describe
"grouped_options_refs"
do
# Override Rails' grouped_options_for_select helper since HTML is harder to work with
def
grouped_options_for_select
(
options
,
*
args
)
options
end
let
(
:options
)
{
grouped_options_refs
}
before
do
# Must be an instance variable
@project
=
create
(
:project
)
end
it
"includes a list of branch names"
do
options
[
0
][
0
].
should
==
'Branches'
options
[
0
][
1
].
should
include
(
'master'
,
'stable'
)
end
it
"includes a list of tag names"
do
options
[
1
][
0
].
should
==
'Tags'
options
[
1
][
1
].
should
include
(
'v0.9.4'
,
'v1.2.0'
)
end
it
"includes a specific commit ref if defined"
do
# Must be an instance variable
@ref
=
'2ed06dc41dbb5936af845b87d79e05bbf24c73b8'
options
[
2
][
0
].
should
==
'Commit'
options
[
2
][
1
].
should
==
[
@ref
]
end
it
"sorts tags in a natural order"
do
# Stub repository.tag_names to make sure we get some valid testing data
expect
(
@project
.
repository
).
to
receive
(
:tag_names
).
and_return
([
"v1.0.9"
,
"v1.0.10"
,
"v2.0"
,
"v3.1.4.2"
,
"v1.0.9a"
])
options
[
1
][
1
].
should
==
[
"v3.1.4.2"
,
"v2.0"
,
"v1.0.10"
,
"v1.0.9a"
,
"v1.0.9"
]
end
end
describe
"user_color_scheme_class"
do
...
...
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