summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorLin Jen-Shin <godfat@godfat.org>2017-05-19 00:57:37 +0800
committerLin Jen-Shin <godfat@godfat.org>2017-05-19 00:57:37 +0800
commitfb3077e67b527f92a917e0f8b6f2745a322bce9a (patch)
treee284fd772454ae0820d4202646343ec7ad9053ef /lib
parentad0a50126cfd02602e942b6bbf012279c98a69c3 (diff)
downloadgitlab-ce-fb3077e67b527f92a917e0f8b6f2745a322bce9a.tar.gz
Complete all legacy builds URL. Tests are added
Diffstat (limited to 'lib')
-rw-r--r--lib/gitlab/routes/legacy_builds.rb44
1 files changed, 44 insertions, 0 deletions
diff --git a/lib/gitlab/routes/legacy_builds.rb b/lib/gitlab/routes/legacy_builds.rb
new file mode 100644
index 00000000000..ecf0c65d70a
--- /dev/null
+++ b/lib/gitlab/routes/legacy_builds.rb
@@ -0,0 +1,44 @@
+
+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