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
Boxiang Sun
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 @@
...
@@ -2,43 +2,60 @@
module
Gitlab
module
Gitlab
module
Routes
module
Routes
class
LegacyBuilds
class
LegacyBuilds
include
Gitlab
::
Routing
.
url_helpers
include
GitlabRoutingHelper
def
initialize
(
map
)
def
initialize
(
map
)
@map
=
map
@map
=
map
end
end
def
draw
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
,
@map
.
get
'/builds(/:id(/*action))'
,
to:
redirect_builds
,
as:
'legacy_build'
,
as:
'legacy_build
s
'
,
format:
false
format:
false
end
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
args
=
params
.
values_at
(
:namespace_id
,
:project_id
,
:id
).
compact
url_helpers
=
Gitlab
::
Routing
.
url_helpers
if
params
[
:id
]
if
params
[
:id
]
case
params
[
:action
]
case
params
[
:action
]
when
'status'
when
'status'
url_helpers
.
status_namespace_project_job_path
(
*
args
,
format:
params
[
:format
])
status_namespace_project_job_path
(
*
args
,
format:
params
[
:format
])
when
'trace'
when
'trace'
url_helpers
.
trace_namespace_project_job_path
(
*
args
,
format:
params
[
:format
])
trace_namespace_project_job_path
(
*
args
,
format:
params
[
:format
])
when
'raw'
when
'raw'
url_helpers
.
raw_namespace_project_job_path
(
*
args
)
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
else
# show
url_helpers
.
namespace_project_job_path
(
*
args
)
namespace_project_job_path
(
*
args
)
end
end
else
# index
else
# index
url_helpers
.
namespace_project_jobs_path
(
*
args
)
namespace_project_jobs_path
(
*
args
)
end
end
end
end
def
fake_project
(
namespace_id
,
project_id
)
Struct
.
new
(
:namespace
,
:to_param
).
new
(
namespace_id
,
project_id
)
end
end
end
end
end
end
end
spec/features/projects/jobs_spec.rb
View file @
876acc7e
...
@@ -482,8 +482,8 @@ feature 'Jobs', :feature do
...
@@ -482,8 +482,8 @@ feature 'Jobs', :feature do
end
end
end
end
describe
"GET /:project/
build
s/:id/trace.json"
do
describe
"GET /:project/
job
s/:id/trace.json"
do
context
"
Build
from project"
do
context
"
Job
from project"
do
before
do
before
do
visit
trace_namespace_project_job_path
(
project
.
namespace
,
project
,
build
,
format: :json
)
visit
trace_namespace_project_job_path
(
project
.
namespace
,
project
,
build
,
format: :json
)
end
end
...
@@ -491,7 +491,7 @@ feature 'Jobs', :feature do
...
@@ -491,7 +491,7 @@ feature 'Jobs', :feature do
it
{
expect
(
page
.
status_code
).
to
eq
(
200
)
}
it
{
expect
(
page
.
status_code
).
to
eq
(
200
)
}
end
end
context
"
Build
from other project"
do
context
"
Job
from other project"
do
before
do
before
do
visit
trace_namespace_project_job_path
(
project
.
namespace
,
project
,
build2
,
format: :json
)
visit
trace_namespace_project_job_path
(
project
.
namespace
,
project
,
build2
,
format: :json
)
end
end
...
@@ -514,8 +514,8 @@ feature 'Jobs', :feature do
...
@@ -514,8 +514,8 @@ feature 'Jobs', :feature do
end
end
end
end
describe
"GET /:project/
build
s/:id/status"
do
describe
"GET /:project/
job
s/:id/status"
do
context
"
Build
from project"
do
context
"
Job
from project"
do
before
do
before
do
visit
status_namespace_project_job_path
(
project
.
namespace
,
project
,
build
)
visit
status_namespace_project_job_path
(
project
.
namespace
,
project
,
build
)
end
end
...
@@ -523,7 +523,7 @@ feature 'Jobs', :feature do
...
@@ -523,7 +523,7 @@ feature 'Jobs', :feature do
it
{
expect
(
page
.
status_code
).
to
eq
(
200
)
}
it
{
expect
(
page
.
status_code
).
to
eq
(
200
)
}
end
end
context
"
Build
from other project"
do
context
"
Job
from other project"
do
before
do
before
do
visit
status_namespace_project_job_path
(
project
.
namespace
,
project
,
build2
)
visit
status_namespace_project_job_path
(
project
.
namespace
,
project
,
build2
)
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