summaryrefslogtreecommitdiff
path: root/config
diff options
context:
space:
mode:
authorLin Jen-Shin <godfat@godfat.org>2017-05-18 21:40:00 +0800
committerLin Jen-Shin <godfat@godfat.org>2017-05-18 21:40:00 +0800
commitad0a50126cfd02602e942b6bbf012279c98a69c3 (patch)
treea9938f6099e905368394411d18f241e7aea8d5bf /config
parentb8ff4b26b5f38e2fcdca487c5b7fc7d19af9ac61 (diff)
downloadgitlab-ce-ad0a50126cfd02602e942b6bbf012279c98a69c3.tar.gz
Use a single route, reducing duplication
Diffstat (limited to 'config')
-rw-r--r--config/routes/project.rb43
1 files changed, 16 insertions, 27 deletions
diff --git a/config/routes/project.rb b/config/routes/project.rb
index 95ca3281a3f..f9d7bceba2c 100644
--- a/config/routes/project.rb
+++ b/config/routes/project.rb
@@ -198,39 +198,28 @@ constraints(ProjectUrlConstrainer.new) do
end
end
- # It's a block, not a hash, disabling style check for hash
- # rubocop:disable Style/AlignHash
- get '/builds/:id/:action', as: 'action_legacy_build',
- to: redirect { |params, req|
- args = params.values_at(:namespace_id, :project_id, :id)
+ redirect_builds_to_jobs = redirect do |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'
- Gitlab::Routing.url_helpers.status_namespace_project_job_path(*args, format: params[:format])
+ url_helpers.status_namespace_project_job_path(*args, format: params[:format])
when 'trace'
- Gitlab::Routing.url_helpers.trace_namespace_project_job_path(*args, format: params[:format])
+ url_helpers.trace_namespace_project_job_path(*args, format: params[:format])
when 'raw'
- Gitlab::Routing.url_helpers.raw_namespace_project_job_path(*args)
- else
- Gitlab::Routing.url_helpers.namespace_project_job_path(*args)
+ url_helpers.raw_namespace_project_job_path(*args)
+ else # show
+ url_helpers.namespace_project_job_path(*args)
end
- }
-
- # It's a block, not a hash, disabling style check for hash
- # rubocop:disable Style/AlignHash
- get '/builds/:id', as: 'legacy_build',
- to: redirect { |params, req|
- Gitlab::Routing.url_helpers.namespace_project_job_path(
- params[:namespace_id], params[:project_id], params[:id])
- }
-
- # It's a block, not a hash, disabling style check for hash
- # rubocop:disable Style/AlignHash
- get '/builds', as: 'legacy_builds',
- to: redirect { |params, req|
- Gitlab::Routing.url_helpers.namespace_project_jobs_path(
- params[:namespace_id], params[:project_id])
- }
+ 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
member do