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
1
Merge Requests
1
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
nexedi
gitlab-ce
Commits
8895abaf
Commit
8895abaf
authored
Mar 06, 2018
by
Mario de la Ossa
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Port of ee-183-common-code-backport to EE
parent
c0c34cda
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
23 additions
and
1 deletion
+23
-1
lib/gitlab/utils.rb
lib/gitlab/utils.rb
+8
-0
spec/lib/gitlab/utils_spec.rb
spec/lib/gitlab/utils_spec.rb
+15
-1
No files found.
lib/gitlab/utils.rb
View file @
8895abaf
...
@@ -68,6 +68,14 @@ module Gitlab
...
@@ -68,6 +68,14 @@ module Gitlab
nil
nil
end
end
# Used in EE
# Accepts either an Array or a String and returns an array
def
ensure_array_from_string
(
string_or_array
)
return
string_or_array
if
string_or_array
.
is_a?
(
Array
)
string_or_array
.
split
(
','
).
map
(
&
:strip
)
end
# EE below
# EE below
def
try_megabytes_to_bytes
(
size
)
def
try_megabytes_to_bytes
(
size
)
Integer
(
size
).
megabytes
Integer
(
size
).
megabytes
...
...
spec/lib/gitlab/utils_spec.rb
View file @
8895abaf
require
'spec_helper'
require
'spec_helper'
describe
Gitlab
::
Utils
do
describe
Gitlab
::
Utils
do
delegate
:to_boolean
,
:boolean_to_yes_no
,
:slugify
,
:random_string
,
:which
,
to: :described_class
delegate
:to_boolean
,
:boolean_to_yes_no
,
:slugify
,
:random_string
,
:which
,
:ensure_array_from_string
,
to: :described_class
describe
'.slugify'
do
describe
'.slugify'
do
{
{
...
@@ -83,4 +83,18 @@ describe Gitlab::Utils do
...
@@ -83,4 +83,18 @@ describe Gitlab::Utils do
expect
(
which
(
'sh'
,
'PATH'
=>
'/bin'
)).
to
eq
(
'/bin/sh'
)
expect
(
which
(
'sh'
,
'PATH'
=>
'/bin'
)).
to
eq
(
'/bin/sh'
)
end
end
end
end
describe
'.ensure_array_from_string'
do
it
'returns the same array if given one'
do
arr
=
[
'a'
,
4
,
true
,
{
test:
1
}]
expect
(
ensure_array_from_string
(
arr
)).
to
eq
(
arr
)
end
it
'turns comma-separated strings into arrays'
do
str
=
'seven, eight, 9, 10'
expect
(
ensure_array_from_string
(
str
)).
to
eq
(
%w[seven eight 9 10]
)
end
end
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