diff options
author | Lin Jen-Shin <godfat@godfat.org> | 2017-05-23 23:42:26 +0800 |
---|---|---|
committer | Lin Jen-Shin <godfat@godfat.org> | 2017-05-24 15:31:30 +0800 |
commit | 524c947eafbc4b710ac862c4e90801b2777d49dc (patch) | |
tree | a3fc430937fd4d40414b0bd307be65189d074111 | |
parent | 43981250c426595c9b3c03a5153ae05d3de2a8e2 (diff) | |
download | gitlab-ce-524c947eafbc4b710ac862c4e90801b2777d49dc.tar.gz |
Add checks before redirect, remove status/trace
compatible urls, which were for javascripts
-rw-r--r-- | app/controllers/projects/build_artifacts_controller.rb | 6 | ||||
-rw-r--r-- | app/controllers/projects/builds_controller.rb | 10 | ||||
-rw-r--r-- | lib/gitlab/routes/legacy_builds.rb | 2 | ||||
-rw-r--r-- | spec/features/projects/jobs_spec.rb | 28 |
4 files changed, 8 insertions, 38 deletions
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 |