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
fb3077e6
Commit
fb3077e6
authored
May 19, 2017
by
Lin Jen-Shin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Complete all legacy builds URL. Tests are added
parent
ad0a5012
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
176 additions
and
23 deletions
+176
-23
config/routes/project.rb
config/routes/project.rb
+2
-22
lib/gitlab/routes/legacy_builds.rb
lib/gitlab/routes/legacy_builds.rb
+44
-0
spec/features/projects/artifacts/browse_spec.rb
spec/features/projects/artifacts/browse_spec.rb
+25
-0
spec/features/projects/artifacts/download_spec.rb
spec/features/projects/artifacts/download_spec.rb
+61
-0
spec/features/projects/artifacts/file_spec.rb
spec/features/projects/artifacts/file_spec.rb
+19
-1
spec/features/projects/artifacts/raw_spec.rb
spec/features/projects/artifacts/raw_spec.rb
+25
-0
No files found.
config/routes/project.rb
View file @
fb3077e6
require
'constraints/project_url_constrainer'
require
'constraints/project_url_constrainer'
require
'gitlab/routes/legacy_builds'
resources
:projects
,
only:
[
:index
,
:new
,
:create
]
resources
:projects
,
only:
[
:index
,
:new
,
:create
]
...
@@ -198,28 +199,7 @@ constraints(ProjectUrlConstrainer.new) do
...
@@ -198,28 +199,7 @@ constraints(ProjectUrlConstrainer.new) do
end
end
end
end
redirect_builds_to_jobs
=
redirect
do
|
params
,
req
|
Gitlab
::
Routes
::
LegacyBuilds
.
new
(
self
).
draw
args
=
params
.
values_at
(
:namespace_id
,
:project_id
,
:id
).
compact
url_helpers
=
Gitlab
::
Routing
.
url_helpers
if
params
[
:id
]
case
params
[
:action
]
when
'status'
url_helpers
.
status_namespace_project_job_path
(
*
args
,
format:
params
[
:format
])
when
'trace'
url_helpers
.
trace_namespace_project_job_path
(
*
args
,
format:
params
[
:format
])
when
'raw'
url_helpers
.
raw_namespace_project_job_path
(
*
args
)
else
# show
url_helpers
.
namespace_project_job_path
(
*
args
)
end
else
# index
url_helpers
.
namespace_project_jobs_path
(
*
args
)
end
end
get
'/builds(/:id(/:action))'
,
to:
redirect_builds_to_jobs
,
as:
'legacy_build'
resources
:hooks
,
only:
[
:index
,
:create
,
:edit
,
:update
,
:destroy
],
constraints:
{
id:
/\d+/
}
do
resources
:hooks
,
only:
[
:index
,
:create
,
:edit
,
:update
,
:destroy
],
constraints:
{
id:
/\d+/
}
do
member
do
member
do
...
...
lib/gitlab/routes/legacy_builds.rb
0 → 100644
View file @
fb3077e6
module
Gitlab
module
Routes
class
LegacyBuilds
def
initialize
(
map
)
@map
=
map
end
def
draw
redirect_builds_to_jobs
=
@map
.
redirect
(
&
method
(
:redirect
))
@map
.
get
'/builds(/:id(/*action))'
,
to:
redirect_builds_to_jobs
,
as:
'legacy_build'
,
format:
false
end
def
redirect
(
params
,
req
)
args
=
params
.
values_at
(
:namespace_id
,
:project_id
,
:id
).
compact
url_helpers
=
Gitlab
::
Routing
.
url_helpers
if
params
[
:id
]
case
params
[
:action
]
when
'status'
url_helpers
.
status_namespace_project_job_path
(
*
args
,
format:
params
[
:format
])
when
'trace'
url_helpers
.
trace_namespace_project_job_path
(
*
args
,
format:
params
[
:format
])
when
'raw'
url_helpers
.
raw_namespace_project_job_path
(
*
args
)
when
String
if
params
[
:id
]
==
'artifacts'
url_helpers
.
latest_succeeded_namespace_project_artifacts_path
(
params
[
:namespace_id
],
params
[
:project_id
],
params
[
:action
],
job:
req
.
GET
[
:job
])
else
"
#{
url_helpers
.
namespace_project_job_path
(
*
args
)
}
/
#{
params
[
:action
]
}
"
end
else
# show
url_helpers
.
namespace_project_job_path
(
*
args
)
end
else
# index
url_helpers
.
namespace_project_jobs_path
(
*
args
)
end
end
end
end
end
spec/features/projects/artifacts/browse_spec.rb
0 → 100644
View file @
fb3077e6
require
'spec_helper'
feature
'Browse artifact'
,
:js
,
feature:
true
do
let
(
:project
)
{
create
(
:project
,
:public
)
}
let
(
:pipeline
)
{
create
(
:ci_empty_pipeline
,
project:
project
,
sha:
project
.
commit
.
sha
,
ref:
'master'
)
}
let
(
:job
)
{
create
(
:ci_build
,
:artifacts
,
pipeline:
pipeline
)
}
def
browse_path
(
path
)
browse_namespace_project_job_artifacts_path
(
project
.
namespace
,
project
,
job
,
path
)
end
context
'when visiting old URL'
do
let
(
:browse_url
)
do
browse_path
(
'other_artifacts_0.1.2'
)
end
before
do
visit
browse_url
.
sub
(
'jobs'
,
'builds'
)
end
it
"redirects to new URL"
do
expect
(
page
.
current_path
).
to
eq
(
browse_url
)
end
end
end
spec/features/projects/artifacts/download_spec.rb
0 → 100644
View file @
fb3077e6
require
'spec_helper'
feature
'Download artifact'
,
:js
,
feature:
true
do
let
(
:project
)
{
create
(
:project
,
:public
)
}
let
(
:pipeline
)
{
create
(
:ci_empty_pipeline
,
status: :success
,
project:
project
,
sha:
project
.
commit
.
sha
,
ref:
'master'
)
}
let
(
:job
)
{
create
(
:ci_build
,
:artifacts
,
:success
,
pipeline:
pipeline
)
}
shared_examples
'downloading'
do
it
'downloads the zip'
do
expect
(
page
.
response_headers
[
'Content-Disposition'
])
.
to
eq
(
%Q{attachment; filename="
#{
job
.
artifacts_file
.
filename
}
"}
)
# Check the content does match, but don't print this as error message
expect
(
page
.
source
.
b
==
job
.
artifacts_file
.
file
.
read
.
b
)
end
end
context
'when downloading'
do
before
do
visit
download_url
end
context
'via job id'
do
let
(
:download_url
)
do
download_namespace_project_job_artifacts_path
(
project
.
namespace
,
project
,
job
)
end
it_behaves_like
'downloading'
end
context
'via branch name and job name'
do
let
(
:download_url
)
do
latest_succeeded_namespace_project_artifacts_path
(
project
.
namespace
,
project
,
"
#{
pipeline
.
ref
}
/download"
,
job:
job
.
name
)
end
it_behaves_like
'downloading'
end
end
context
'when visiting old URL'
do
before
do
visit
download_url
.
sub
(
'jobs'
,
'builds'
)
end
context
'via job id'
do
let
(
:download_url
)
do
download_namespace_project_job_artifacts_path
(
project
.
namespace
,
project
,
job
)
end
it_behaves_like
'downloading'
end
context
'via branch name and job name'
do
let
(
:download_url
)
do
latest_succeeded_namespace_project_artifacts_path
(
project
.
namespace
,
project
,
"
#{
pipeline
.
ref
}
/download"
,
job:
job
.
name
)
end
it_behaves_like
'downloading'
end
end
end
spec/features/projects/artifacts/file_spec.rb
View file @
fb3077e6
...
@@ -6,7 +6,11 @@ feature 'Artifact file', :js, feature: true do
...
@@ -6,7 +6,11 @@ feature 'Artifact file', :js, feature: true do
let
(
:build
)
{
create
(
:ci_build
,
:artifacts
,
pipeline:
pipeline
)
}
let
(
:build
)
{
create
(
:ci_build
,
:artifacts
,
pipeline:
pipeline
)
}
def
visit_file
(
path
)
def
visit_file
(
path
)
visit
file_namespace_project_job_artifacts_path
(
project
.
namespace
,
project
,
build
,
path
)
visit
file_path
(
path
)
end
def
file_path
(
path
)
file_namespace_project_job_artifacts_path
(
project
.
namespace
,
project
,
build
,
path
)
end
end
context
'Text file'
do
context
'Text file'
do
...
@@ -56,4 +60,18 @@ feature 'Artifact file', :js, feature: true do
...
@@ -56,4 +60,18 @@ feature 'Artifact file', :js, feature: true do
end
end
end
end
end
end
context
'when visiting old URL'
do
let
(
:file_url
)
do
file_path
(
'other_artifacts_0.1.2/doc_sample.txt'
)
end
before
do
visit
file_url
.
sub
(
'jobs'
,
'builds'
)
end
it
"redirects to new URL"
do
expect
(
page
.
current_path
).
to
eq
(
file_url
)
end
end
end
end
spec/features/projects/artifacts/raw_spec.rb
0 → 100644
View file @
fb3077e6
require
'spec_helper'
feature
'Raw artifact'
,
:js
,
feature:
true
do
let
(
:project
)
{
create
(
:project
,
:public
)
}
let
(
:pipeline
)
{
create
(
:ci_empty_pipeline
,
project:
project
,
sha:
project
.
commit
.
sha
,
ref:
'master'
)
}
let
(
:job
)
{
create
(
:ci_build
,
:artifacts
,
pipeline:
pipeline
)
}
def
raw_path
(
path
)
raw_namespace_project_job_artifacts_path
(
project
.
namespace
,
project
,
job
,
path
)
end
context
'when visiting old URL'
do
let
(
:raw_url
)
do
raw_path
(
'other_artifacts_0.1.2/doc_sample.txt'
)
end
before
do
visit
raw_url
.
sub
(
'jobs'
,
'builds'
)
end
it
"redirects to new URL"
do
expect
(
page
.
current_path
).
to
eq
(
raw_url
)
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