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
iv
gitlab-ce
Commits
cd3b8bbd
Commit
cd3b8bbd
authored
Jan 04, 2016
by
Grzegorz Bizon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add method that checks if path exists in `StringPath`
parent
a5e1905d
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
18 additions
and
1 deletion
+18
-1
app/controllers/projects/artifacts_controller.rb
app/controllers/projects/artifacts_controller.rb
+1
-1
lib/gitlab/string_path.rb
lib/gitlab/string_path.rb
+4
-0
spec/lib/gitlab/string_path_spec.rb
spec/lib/gitlab/string_path_spec.rb
+13
-0
No files found.
app/controllers/projects/artifacts_controller.rb
View file @
cd3b8bbd
...
@@ -17,7 +17,7 @@ class Projects::ArtifactsController < Projects::ApplicationController
...
@@ -17,7 +17,7 @@ class Projects::ArtifactsController < Projects::ApplicationController
def
browse
def
browse
return
render_404
unless
build
.
artifacts?
return
render_404
unless
build
.
artifacts?
@path
=
build
.
artifacts_metadata_string_path
(
params
[
:path
]
||
'./'
)
@path
=
build
.
artifacts_metadata_string_path
(
params
[
:path
]
||
'./'
)
return
render_404
if
@path
.
universe
.
empty
?
return
render_404
unless
@path
.
exists
?
end
end
private
private
...
...
lib/gitlab/string_path.rb
View file @
cd3b8bbd
...
@@ -19,6 +19,10 @@ module Gitlab
...
@@ -19,6 +19,10 @@ module Gitlab
@path
@path
end
end
def
exists?
@path
==
'./'
||
@universe
.
include?
(
@path
)
end
def
absolute?
def
absolute?
@path
.
start_with?
(
'/'
)
@path
.
start_with?
(
'/'
)
end
end
...
...
spec/lib/gitlab/string_path_spec.rb
View file @
cd3b8bbd
...
@@ -32,6 +32,7 @@ describe Gitlab::StringPath do
...
@@ -32,6 +32,7 @@ describe Gitlab::StringPath do
it
{
is_expected
.
to
be_file
}
it
{
is_expected
.
to
be_file
}
it
{
is_expected
.
to
have_parent
}
it
{
is_expected
.
to
have_parent
}
it
{
is_expected
.
to_not
have_descendants
}
it
{
is_expected
.
to_not
have_descendants
}
it
{
is_expected
.
to
exist
}
describe
'#basename'
do
describe
'#basename'
do
subject
{
|
example
|
path
(
example
).
basename
}
subject
{
|
example
|
path
(
example
).
basename
}
...
@@ -170,4 +171,16 @@ describe Gitlab::StringPath do
...
@@ -170,4 +171,16 @@ describe Gitlab::StringPath do
it
{
is_expected
.
to
eq
'/path/file1'
}
it
{
is_expected
.
to
eq
'/path/file1'
}
end
end
describe
'#exists?'
,
path:
'another_file'
do
subject
{
|
example
|
path
(
example
).
exists?
}
it
{
is_expected
.
to
be
true
}
end
describe
'#exists?'
,
path:
'./non_existent/'
do
let
(
:universe
)
{
[
'./something'
]
}
subject
{
|
example
|
path
(
example
).
exists?
}
it
{
is_expected
.
to
be
false
}
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