diff options
-rw-r--r-- | app/controllers/projects/builds_controller.rb | 15 | ||||
-rw-r--r-- | app/controllers/projects/commit_controller.rb | 11 | ||||
-rw-r--r-- | config/routes.rb | 11 |
3 files changed, 13 insertions, 24 deletions
diff --git a/app/controllers/projects/builds_controller.rb b/app/controllers/projects/builds_controller.rb index 9e89296e71d..8ca6e02dab8 100644 --- a/app/controllers/projects/builds_controller.rb +++ b/app/controllers/projects/builds_controller.rb @@ -1,10 +1,12 @@ class Projects::BuildsController < Projects::ApplicationController before_action :build, except: [:index, :cancel_all] - before_action :authorize_read_build!, except: [:cancel, :cancel_all, :retry] before_action :authorize_update_build!, except: [:index, :show, :status] + layout 'project' - layout "project" + # Skip authentication for status badge only + skip_before_action :authenticate_user!, :reject_blocked!, :project, + :repository, :authorize_manage_builds!, :build, only: [:badge] def index @scope = params[:scope] @@ -24,7 +26,6 @@ class Projects::BuildsController < Projects::ApplicationController def cancel_all @project.builds.running_or_pending.each(&:cancel) - redirect_to namespace_project_builds_path(project.namespace, project) end @@ -47,7 +48,6 @@ class Projects::BuildsController < Projects::ApplicationController end build = Ci::Build.retry(@build) - redirect_to build_path(build) end @@ -57,10 +57,15 @@ class Projects::BuildsController < Projects::ApplicationController def cancel @build.cancel - redirect_to build_path(@build) end + def badge + project = Project.find_with_namespace("#{params[:namespace_id]}/#{params[:project_id]}") + image = Ci::ImageForBuildService.new.execute(project, ref: params[:ref]) + send_file(image.path, filename: image.name, disposition: 'inline', type: 'image/svg+xml') + end + private def build diff --git a/app/controllers/projects/commit_controller.rb b/app/controllers/projects/commit_controller.rb index 493cd332d9f..21f4d9f44ec 100644 --- a/app/controllers/projects/commit_controller.rb +++ b/app/controllers/projects/commit_controller.rb @@ -10,11 +10,6 @@ class Projects::CommitController < Projects::ApplicationController before_action :commit before_action :define_show_vars, only: [:show, :builds] - # Skip authentication for status badge only - skip_before_action :authenticate_user!, :reject_blocked!, :project, - :repository, :require_non_empty_project, :authorize_download_code!, - :commit, only: [:badge] - def show return git_not_found! unless @commit @@ -62,12 +57,6 @@ class Projects::CommitController < Projects::ApplicationController render layout: false end - def badge - project = Project.find_with_namespace("#{params[:namespace_id]}/#{params[:project_id]}") - image = Ci::ImageForBuildService.new.execute(project, ref: params[:id]) - send_file(image.path, filename: image.name, disposition: 'inline', type: 'image/svg+xml') - end - private def commit diff --git a/config/routes.rb b/config/routes.rb index 6b710bc45ea..ea14ba38198 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -493,13 +493,6 @@ Rails.application.routes.draw do constraints: { id: /(?:[^.]|\.(?!atom$))+/, format: /atom/ }, as: :commits ) - - get( - '/status/*id/badge', - to: 'commit#badge', - constraints: { format: /png/ }, - as: :build_badge - ) end resource :avatar, only: [:show, :destroy] @@ -615,9 +608,11 @@ Rails.application.routes.draw do resource :variables, only: [:show, :update] resources :triggers, only: [:index, :create, :destroy] - resources :builds, only: [:index, :show] do + resources :builds, only: [:index, :show], constraints: { id: /\d+/ } do collection do post :cancel_all + get :badge, path: 'status/*ref/badge', + constraints: { ref: Gitlab::Regex.git_reference_regex, format: /svg/ } end member do |