diff options
-rw-r--r-- | app/controllers/projects/artifacts_controller.rb | 10 | ||||
-rw-r--r-- | app/helpers/gitlab_routing_helper.rb | 15 |
2 files changed, 18 insertions, 7 deletions
diff --git a/app/controllers/projects/artifacts_controller.rb b/app/controllers/projects/artifacts_controller.rb index 5cc6d643b64..8261a73c642 100644 --- a/app/controllers/projects/artifacts_controller.rb +++ b/app/controllers/projects/artifacts_controller.rb @@ -35,14 +35,10 @@ class Projects::ArtifactsController < Projects::ApplicationController end def latest_succeeded - path = params[:path] + target_url = artifacts_action_url(params[:path], project, build) - if %w[download browse file].include?(path) - redirect_to send( - "#{path}_namespace_project_build_artifacts_url", - project.namespace, - project, - build) + if target_url + redirect_to(target_url) else render_404 end diff --git a/app/helpers/gitlab_routing_helper.rb b/app/helpers/gitlab_routing_helper.rb index 5386ddadc62..bc4d976ae68 100644 --- a/app/helpers/gitlab_routing_helper.rb +++ b/app/helpers/gitlab_routing_helper.rb @@ -149,4 +149,19 @@ module GitlabRoutingHelper def resend_invite_group_member_path(group_member, *args) resend_invite_group_group_member_path(group_member.source, group_member) end + + # Artifacts + + def artifacts_action_url(path, project, build) + args = [project.namespace, project, build] + + case path + when 'download' + download_namespace_project_build_artifacts_url(*args) + when 'browse' + browse_namespace_project_build_artifacts_url(*args) + when 'file' + file_namespace_project_build_artifacts_url(*args) + end + end end |