Remove cancel all action in Jobs Controller
This commit is contained in:
parent
f5b3060920
commit
5eeeaff2db
3 changed files with 2 additions and 57 deletions
|
@ -4,10 +4,10 @@ class Projects::JobsController < Projects::ApplicationController
|
||||||
include SendFileUpload
|
include SendFileUpload
|
||||||
include ContinueParams
|
include ContinueParams
|
||||||
|
|
||||||
before_action :build, except: [:index, :cancel_all]
|
before_action :build, except: [:index]
|
||||||
before_action :authorize_read_build!
|
before_action :authorize_read_build!
|
||||||
before_action :authorize_update_build!,
|
before_action :authorize_update_build!,
|
||||||
except: [:index, :show, :status, :raw, :trace, :cancel_all, :erase]
|
except: [:index, :show, :status, :raw, :trace, :erase]
|
||||||
before_action :authorize_erase_build!, only: [:erase]
|
before_action :authorize_erase_build!, only: [:erase]
|
||||||
before_action :authorize_use_build_terminal!, only: [:terminal, :terminal_websocket_authorize]
|
before_action :authorize_use_build_terminal!, only: [:terminal, :terminal_websocket_authorize]
|
||||||
before_action :verify_api_request!, only: :terminal_websocket_authorize
|
before_action :verify_api_request!, only: :terminal_websocket_authorize
|
||||||
|
@ -39,16 +39,6 @@ class Projects::JobsController < Projects::ApplicationController
|
||||||
end
|
end
|
||||||
# rubocop: enable CodeReuse/ActiveRecord
|
# rubocop: enable CodeReuse/ActiveRecord
|
||||||
|
|
||||||
def cancel_all
|
|
||||||
return access_denied! unless can?(current_user, :update_build, project)
|
|
||||||
|
|
||||||
@project.builds.running_or_pending.each do |build|
|
|
||||||
build.cancel if can?(current_user, :update_build, build)
|
|
||||||
end
|
|
||||||
|
|
||||||
redirect_to project_jobs_path(project)
|
|
||||||
end
|
|
||||||
|
|
||||||
# rubocop: disable CodeReuse/ActiveRecord
|
# rubocop: disable CodeReuse/ActiveRecord
|
||||||
def show
|
def show
|
||||||
@pipeline = @build.pipeline
|
@pipeline = @build.pipeline
|
||||||
|
|
|
@ -255,7 +255,6 @@ constraints(::Constraints::ProjectUrlConstrainer.new) do
|
||||||
|
|
||||||
resources :jobs, only: [:index, :show], constraints: { id: /\d+/ } do
|
resources :jobs, only: [:index, :show], constraints: { id: /\d+/ } do
|
||||||
collection do
|
collection do
|
||||||
post :cancel_all
|
|
||||||
|
|
||||||
resources :artifacts, only: [] do
|
resources :artifacts, only: [] do
|
||||||
collection do
|
collection do
|
||||||
|
|
|
@ -770,50 +770,6 @@ describe Projects::JobsController, :clean_gitlab_redis_shared_state do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe 'POST cancel_all' do
|
|
||||||
before do
|
|
||||||
project.add_developer(user)
|
|
||||||
sign_in(user)
|
|
||||||
end
|
|
||||||
|
|
||||||
context 'when jobs are cancelable' do
|
|
||||||
before do
|
|
||||||
create_list(:ci_build, 2, :cancelable, pipeline: pipeline)
|
|
||||||
|
|
||||||
post_cancel_all
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'redirects to a index page' do
|
|
||||||
expect(response).to have_gitlab_http_status(:found)
|
|
||||||
expect(response).to redirect_to(namespace_project_jobs_path)
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'transits to canceled' do
|
|
||||||
expect(Ci::Build.all).to all(be_canceled)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
context 'when jobs are not cancelable' do
|
|
||||||
before do
|
|
||||||
create_list(:ci_build, 2, :canceled, pipeline: pipeline)
|
|
||||||
|
|
||||||
post_cancel_all
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'redirects to a index page' do
|
|
||||||
expect(response).to have_gitlab_http_status(:found)
|
|
||||||
expect(response).to redirect_to(namespace_project_jobs_path)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def post_cancel_all
|
|
||||||
post :cancel_all, params: {
|
|
||||||
namespace_id: project.namespace,
|
|
||||||
project_id: project
|
|
||||||
}
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
describe 'POST erase' do
|
describe 'POST erase' do
|
||||||
let(:role) { :maintainer }
|
let(:role) { :maintainer }
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue