From a1debf5cf029edc550d7d46eff7ef4ab1b51a2b2 Mon Sep 17 00:00:00 2001 From: Filipa Lacerda Date: Mon, 10 Apr 2017 11:30:06 +0100 Subject: Retry and cancel endpoints send 204 json response. Request is made with type json --- .../pipelines/services/pipelines_service.js | 2 +- app/controllers/projects/pipelines_controller.rb | 20 ++++++++++++++++++-- 2 files changed, 19 insertions(+), 3 deletions(-) (limited to 'app') diff --git a/app/assets/javascripts/pipelines/services/pipelines_service.js b/app/assets/javascripts/pipelines/services/pipelines_service.js index 255cd513490..b21f84b4545 100644 --- a/app/assets/javascripts/pipelines/services/pipelines_service.js +++ b/app/assets/javascripts/pipelines/services/pipelines_service.js @@ -40,6 +40,6 @@ export default class PipelinesService { * @return {Promise} */ postAction(endpoint) { - return Vue.http.post(endpoint, {}, { emulateJSON: true }); + return Vue.http.post(`${endpoint}.json`); } } diff --git a/app/controllers/projects/pipelines_controller.rb b/app/controllers/projects/pipelines_controller.rb index 454b8ee17af..6d77b9c38fa 100644 --- a/app/controllers/projects/pipelines_controller.rb +++ b/app/controllers/projects/pipelines_controller.rb @@ -92,13 +92,29 @@ class Projects::PipelinesController < Projects::ApplicationController def retry pipeline.retry_failed(current_user) - redirect_back_or_default default: namespace_project_pipelines_path(project.namespace, project) + respond_to do |format| + format.html do + redirect_back_or_default default: namespace_project_pipelines_path(project.namespace, project) + end + + format.json do + render status: 204 + end + end end def cancel pipeline.cancel_running - redirect_back_or_default default: namespace_project_pipelines_path(project.namespace, project) + respond_to do |format| + format.html do + redirect_back_or_default default: namespace_project_pipelines_path(project.namespace, project) + end + + format.json do + render status: 204 + end + end end def charts -- cgit v1.2.3 From b8960354fecdaf0a19a370f00f7caad147c57e62 Mon Sep 17 00:00:00 2001 From: Grzegorz Bizon Date: Wed, 12 Apr 2017 09:44:16 +0200 Subject: Respond with no content for pipeline JSON actions --- app/controllers/projects/pipelines_controller.rb | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) (limited to 'app') diff --git a/app/controllers/projects/pipelines_controller.rb b/app/controllers/projects/pipelines_controller.rb index 6d77b9c38fa..95478da019e 100644 --- a/app/controllers/projects/pipelines_controller.rb +++ b/app/controllers/projects/pipelines_controller.rb @@ -97,9 +97,7 @@ class Projects::PipelinesController < Projects::ApplicationController redirect_back_or_default default: namespace_project_pipelines_path(project.namespace, project) end - format.json do - render status: 204 - end + format.json { head :no_content } end end @@ -111,9 +109,7 @@ class Projects::PipelinesController < Projects::ApplicationController redirect_back_or_default default: namespace_project_pipelines_path(project.namespace, project) end - format.json do - render status: 204 - end + format.json { head :no_content } end end -- cgit v1.2.3 From c68bf4327b3e4811e001adeca84ad0f88c421455 Mon Sep 17 00:00:00 2001 From: Grzegorz Bizon Date: Mon, 24 Apr 2017 16:34:53 +0200 Subject: Use wrap_parameters in pipelines controller This makes it possible to workaround a bug in `safe_constantize` which caused a `LoadError` exception when doing ``` "Pipeline".safe_constantize LoadError: Unable to autoload constant Pipeline, expected /home/grzesiek/gdk/gitlab/app/models/ci/pipeline.rb to define it ``` See https://github.com/rails/rails/issues/28854 for more details. --- app/controllers/projects/pipelines_controller.rb | 2 ++ 1 file changed, 2 insertions(+) (limited to 'app') diff --git a/app/controllers/projects/pipelines_controller.rb b/app/controllers/projects/pipelines_controller.rb index 95478da019e..2908036607a 100644 --- a/app/controllers/projects/pipelines_controller.rb +++ b/app/controllers/projects/pipelines_controller.rb @@ -6,6 +6,8 @@ class Projects::PipelinesController < Projects::ApplicationController before_action :authorize_update_pipeline!, only: [:retry, :cancel] before_action :builds_enabled, only: :charts + wrap_parameters Ci::Pipeline + def index @scope = params[:scope] @pipelines = PipelinesFinder -- cgit v1.2.3