Commit d7bbee75 authored by Lin Jen-Shin's avatar Lin Jen-Shin

Update routes based on feedback from:

https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/5142#note_13058785

And note that job/build_name could contain `/`
parent e01c421b
...@@ -61,7 +61,7 @@ class Projects::ArtifactsController < Projects::ApplicationController ...@@ -61,7 +61,7 @@ class Projects::ArtifactsController < Projects::ApplicationController
def build_from_ref def build_from_ref
if params[:ref_name] if params[:ref_name]
builds = project.builds_for(params[:build_name], params[:ref_name]) builds = project.builds_for(params[:job], params[:ref_name])
builds.success.latest.first builds.success.latest.first
end end
......
...@@ -733,16 +733,17 @@ Rails.application.routes.draw do ...@@ -733,16 +733,17 @@ Rails.application.routes.draw do
resources :environments, only: [:index, :show, :new, :create, :destroy] resources :environments, only: [:index, :show, :new, :create, :destroy]
resources :artifacts, only: [] do
collection do
get :search, path: ':ref_name/:build_name/*path', format: false,
constraints: { ref_name: /.+/ } # ref could have /
end
end
resources :builds, only: [:index, :show], constraints: { id: /\d+/ } do resources :builds, only: [:index, :show], constraints: { id: /\d+/ } do
collection do collection do
post :cancel_all post :cancel_all
resources :artifacts, only: [] do
collection do
get :search, path: ':ref_name/*path',
format: false,
constraints: { ref_name: /.+/ } # could have /
end
end
end end
member do member do
......
...@@ -2,7 +2,7 @@ require 'spec_helper' ...@@ -2,7 +2,7 @@ require 'spec_helper'
require_relative '../shared/artifacts_context' require_relative '../shared/artifacts_context'
describe Projects::ArtifactsController do describe Projects::ArtifactsController do
describe 'GET /:project/artifacts/:ref/:build_name/browse' do describe 'GET /:project/builds/artifacts/:ref_name/browse?job=name' do
include_context 'artifacts from ref and build name' include_context 'artifacts from ref and build name'
before do before do
...@@ -10,13 +10,13 @@ describe Projects::ArtifactsController do ...@@ -10,13 +10,13 @@ describe Projects::ArtifactsController do
end end
def path_from_ref( def path_from_ref(
ref = pipeline.sha, build_name = build.name, path = 'browse') ref = pipeline.sha, job = build.name, path = 'browse')
search_namespace_project_artifacts_path( search_namespace_project_artifacts_path(
project.namespace, project.namespace,
project, project,
ref, ref,
build_name, path,
path) job: job)
end end
context '404' do context '404' do
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment