diff --git a/app/controllers/projects/build_artifacts_controller.rb b/app/controllers/projects/build_artifacts_controller.rb index 873246f484e..f34a198634e 100644 --- a/app/controllers/projects/build_artifacts_controller.rb +++ b/app/controllers/projects/build_artifacts_controller.rb @@ -2,7 +2,9 @@ class Projects::BuildArtifactsController < Projects::ApplicationController include ExtractsPath include RendersBlob + before_action :authorize_read_build! before_action :extract_ref_name_and_path + before_action :validate_artifacts! def download redirect_to download_namespace_project_job_artifacts_path(project.namespace, project, job) @@ -26,6 +28,10 @@ class Projects::BuildArtifactsController < Projects::ApplicationController private + def validate_artifacts! + render_404 unless job && job.artifacts? + end + def extract_ref_name_and_path return unless params[:ref_name_and_path] diff --git a/app/controllers/projects/builds_controller.rb b/app/controllers/projects/builds_controller.rb index 013797a7313..1334a231788 100644 --- a/app/controllers/projects/builds_controller.rb +++ b/app/controllers/projects/builds_controller.rb @@ -1,4 +1,6 @@ class Projects::BuildsController < Projects::ApplicationController + before_action :authorize_read_build! + def index redirect_to namespace_project_jobs_path(project.namespace, project) end @@ -7,14 +9,6 @@ class Projects::BuildsController < Projects::ApplicationController redirect_to namespace_project_job_path(project.namespace, project, job) end - def trace - redirect_to trace_namespace_project_job_path(project.namespace, project, job, format: params[:format]) - end - - def status - redirect_to status_namespace_project_job_path(project.namespace, project, job, format: params[:format]) - end - def raw redirect_to raw_namespace_project_job_path(project.namespace, project, job) end diff --git a/lib/gitlab/routes/legacy_builds.rb b/lib/gitlab/routes/legacy_builds.rb index cbb8b960c7e..1b6f6df26a2 100644 --- a/lib/gitlab/routes/legacy_builds.rb +++ b/lib/gitlab/routes/legacy_builds.rb @@ -22,8 +22,6 @@ module Gitlab end member do - get :status - get :trace, defaults: { format: 'json' } get :raw end diff --git a/spec/features/projects/jobs_spec.rb b/spec/features/projects/jobs_spec.rb index 984d9bdb58c..f8d7b9eccb1 100644 --- a/spec/features/projects/jobs_spec.rb +++ b/spec/features/projects/jobs_spec.rb @@ -498,20 +498,6 @@ feature 'Jobs', :feature do it { expect(page.status_code).to eq(404) } end - - context "when visiting old URL" do - let(:trace_job_url) do - trace_namespace_project_job_path(project.namespace, project, build, format: :json) - end - - before do - visit trace_job_url.sub('jobs', 'builds') - end - - it "redirects to new URL" do - expect(page.current_path).to eq(trace_job_url) - end - end end describe "GET /:project/jobs/:id/status" do @@ -530,19 +516,5 @@ feature 'Jobs', :feature do it { expect(page.status_code).to eq(404) } end - - context "when visiting old URL" do - let(:status_job_url) do - status_namespace_project_job_path(project.namespace, project, build) - end - - before do - visit status_job_url.sub('jobs', 'builds') - end - - it "redirects to new URL" do - expect(page.current_path).to eq(status_job_url) - end - end end end