diff options
author | Rémy Coutable <remy@rymai.me> | 2017-04-28 09:38:34 +0000 |
---|---|---|
committer | Rémy Coutable <remy@rymai.me> | 2017-04-28 09:38:34 +0000 |
commit | 7c8aadf85911d900e3ff50ed54ae9b10e8a755d8 (patch) | |
tree | f6b628a6e8d6baea557ed989e669a830ec6873b0 /app | |
parent | 00fd0259e5878957320ef2adc4940cbd73614add (diff) | |
parent | 73ac7b2dd6ad31b0ab3191d123cc0b17c669cefb (diff) | |
download | gitlab-ce-7c8aadf85911d900e3ff50ed54ae9b10e8a755d8.tar.gz |
Merge branch '29181-add-more-tests-for-spec-controllers-projects-builds-controller-spec-rb' into 'master'
Resolve "Add more tests for spec/controllers/projects/builds_controller_spec.rb"
Closes #29181
See merge request !10244
Diffstat (limited to 'app')
-rw-r--r-- | app/controllers/application_controller.rb | 4 | ||||
-rw-r--r-- | app/controllers/projects/builds_controller.rb | 15 |
2 files changed, 14 insertions, 5 deletions
diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index e77094fe2a8..e48f0963ef4 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -118,6 +118,10 @@ class ApplicationController < ActionController::Base end end + def respond_422 + head :unprocessable_entity + end + def no_cache_headers response.headers["Cache-Control"] = "no-cache, no-store, max-age=0, must-revalidate" response.headers["Pragma"] = "no-cache" diff --git a/app/controllers/projects/builds_controller.rb b/app/controllers/projects/builds_controller.rb index 04e8cdf6256..e24fc45d166 100644 --- a/app/controllers/projects/builds_controller.rb +++ b/app/controllers/projects/builds_controller.rb @@ -1,6 +1,6 @@ class Projects::BuildsController < Projects::ApplicationController before_action :build, except: [:index, :cancel_all] - before_action :authorize_read_build!, except: [:cancel, :cancel_all, :retry, :play] + before_action :authorize_read_build!, only: [:index, :show, :status, :raw, :trace] before_action :authorize_update_build!, except: [:index, :show, :status, :raw, :trace] layout 'project' @@ -60,20 +60,22 @@ class Projects::BuildsController < Projects::ApplicationController end def retry - return render_404 unless @build.retryable? + return respond_422 unless @build.retryable? build = Ci::Build.retry(@build, current_user) redirect_to build_path(build) end def play - return render_404 unless @build.playable? + return respond_422 unless @build.playable? build = @build.play(current_user) redirect_to build_path(build) end def cancel + return respond_422 unless @build.cancelable? + @build.cancel redirect_to build_path(@build) end @@ -85,9 +87,12 @@ class Projects::BuildsController < Projects::ApplicationController end def erase - @build.erase(erased_by: current_user) - redirect_to namespace_project_build_path(project.namespace, project, @build), + if @build.erase(erased_by: current_user) + redirect_to namespace_project_build_path(project.namespace, project, @build), notice: "Build has been successfully erased!" + else + respond_422 + end end def raw |