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
876acc7e
Commit
876acc7e
authored
May 19, 2017
by
Lin Jen-Shin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Separate artifacts from builds, reusing artifacts_action_path
parent
fb3077e6
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
39 additions
and
22 deletions
+39
-22
lib/gitlab/routes/legacy_builds.rb
lib/gitlab/routes/legacy_builds.rb
+33
-16
spec/features/projects/jobs_spec.rb
spec/features/projects/jobs_spec.rb
+6
-6
No files found.
lib/gitlab/routes/legacy_builds.rb
View file @
876acc7e
...
...
@@ -2,43 +2,60 @@
module
Gitlab
module
Routes
class
LegacyBuilds
include
Gitlab
::
Routing
.
url_helpers
include
GitlabRoutingHelper
def
initialize
(
map
)
@map
=
map
end
def
draw
redirect_builds_to_jobs
=
@map
.
redirect
(
&
method
(
:redirect
))
redirect_artifacts
=
@map
.
redirect
(
&
method
(
:redirect_artifacts
))
redirect_builds
=
@map
.
redirect
(
&
method
(
:redirect_builds
))
@map
.
get
'/builds(/:id)/artifacts/*action'
,
to:
redirect_artifacts
,
as:
'legacy_artifacts'
,
format:
false
@map
.
get
'/builds(/:id(/*action))'
,
to:
redirect_builds
_to_jobs
,
as:
'legacy_build'
,
@map
.
get
'/builds(/:id(/*action))'
,
to:
redirect_builds
,
as:
'legacy_build
s
'
,
format:
false
end
def
redirect
(
params
,
req
)
private
def
redirect_artifacts
(
params
,
req
)
if
params
[
:id
]
project
=
fake_project
(
*
params
.
values_at
(
:namespace_id
,
:project_id
))
artifacts_action_path
(
params
[
:action
],
project
,
params
[
:id
])
else
latest_succeeded_namespace_project_artifacts_path
(
params
[
:namespace_id
],
params
[
:project_id
],
params
[
:action
],
job:
req
.
GET
[
:job
])
end
end
def
redirect_builds
(
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
])
status_namespace_project_job_path
(
*
args
,
format:
params
[
:format
])
when
'trace'
url_helpers
.
trace_namespace_project_job_path
(
*
args
,
format:
params
[
:format
])
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
raw_namespace_project_job_path
(
*
args
)
else
# show
url_helpers
.
namespace_project_job_path
(
*
args
)
namespace_project_job_path
(
*
args
)
end
else
# index
url_helpers
.
namespace_project_jobs_path
(
*
args
)
namespace_project_jobs_path
(
*
args
)
end
end
def
fake_project
(
namespace_id
,
project_id
)
Struct
.
new
(
:namespace
,
:to_param
).
new
(
namespace_id
,
project_id
)
end
end
end
end
spec/features/projects/jobs_spec.rb
View file @
876acc7e
...
...
@@ -482,8 +482,8 @@ feature 'Jobs', :feature do
end
end
describe
"GET /:project/
build
s/:id/trace.json"
do
context
"
Build
from project"
do
describe
"GET /:project/
job
s/:id/trace.json"
do
context
"
Job
from project"
do
before
do
visit
trace_namespace_project_job_path
(
project
.
namespace
,
project
,
build
,
format: :json
)
end
...
...
@@ -491,7 +491,7 @@ feature 'Jobs', :feature do
it
{
expect
(
page
.
status_code
).
to
eq
(
200
)
}
end
context
"
Build
from other project"
do
context
"
Job
from other project"
do
before
do
visit
trace_namespace_project_job_path
(
project
.
namespace
,
project
,
build2
,
format: :json
)
end
...
...
@@ -514,8 +514,8 @@ feature 'Jobs', :feature do
end
end
describe
"GET /:project/
build
s/:id/status"
do
context
"
Build
from project"
do
describe
"GET /:project/
job
s/:id/status"
do
context
"
Job
from project"
do
before
do
visit
status_namespace_project_job_path
(
project
.
namespace
,
project
,
build
)
end
...
...
@@ -523,7 +523,7 @@ feature 'Jobs', :feature do
it
{
expect
(
page
.
status_code
).
to
eq
(
200
)
}
end
context
"
Build
from other project"
do
context
"
Job
from other project"
do
before
do
visit
status_namespace_project_job_path
(
project
.
namespace
,
project
,
build2
)
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