summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKamil Trzciński <ayufan@ayufan.eu>2017-05-05 10:01:21 +0000
committerKamil Trzciński <ayufan@ayufan.eu>2017-05-05 10:01:21 +0000
commita5347fe58f6ace1ced67fa32a8469ba4e2819606 (patch)
treee43e4ebf00fed4a0c8e0f931bf09193f37db7f66
parent07eac529fc0ec30ff6bea2bba01c68b72fee4f14 (diff)
parent4f3dc19aafdd71aedb6b086da5707315a9a51ace (diff)
downloadgitlab-ce-a5347fe58f6ace1ced67fa32a8469ba4e2819606.tar.gz
Merge branch '30237-pipelines-actions-make-2-requests' into 'master'
Resolve: "Pipelines: When we retry a pipeline 2 requests are made to the pipelines endpoint" Closes #30237 See merge request !10584
-rw-r--r--app/assets/javascripts/pipelines/services/pipelines_service.js2
-rw-r--r--app/controllers/projects/pipelines_controller.rb18
-rw-r--r--spec/controllers/projects/pipelines_controller_spec.rb36
3 files changed, 53 insertions, 3 deletions
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..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
@@ -92,13 +94,25 @@ 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 { head :no_content }
+ 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 { head :no_content }
+ end
end
def charts
diff --git a/spec/controllers/projects/pipelines_controller_spec.rb b/spec/controllers/projects/pipelines_controller_spec.rb
index b9bacc5a64a..1b47d163c0b 100644
--- a/spec/controllers/projects/pipelines_controller_spec.rb
+++ b/spec/controllers/projects/pipelines_controller_spec.rb
@@ -5,6 +5,8 @@ describe Projects::PipelinesController do
let(:project) { create(:empty_project, :public) }
before do
+ project.add_developer(user)
+
sign_in(user)
end
@@ -87,4 +89,38 @@ describe Projects::PipelinesController do
expect(json_response['favicon']).to eq "/assets/ci_favicons/#{status.favicon}.ico"
end
end
+
+ describe 'POST retry.json' do
+ let!(:pipeline) { create(:ci_pipeline, :failed, project: project) }
+ let!(:build) { create(:ci_build, :failed, pipeline: pipeline) }
+
+ before do
+ post :retry, namespace_id: project.namespace,
+ project_id: project,
+ id: pipeline.id,
+ format: :json
+ end
+
+ it 'retries a pipeline without returning any content' do
+ expect(response).to have_http_status(:no_content)
+ expect(build.reload).to be_retried
+ end
+ end
+
+ describe 'POST cancel.json' do
+ let!(:pipeline) { create(:ci_pipeline, project: project) }
+ let!(:build) { create(:ci_build, :running, pipeline: pipeline) }
+
+ before do
+ post :cancel, namespace_id: project.namespace,
+ project_id: project,
+ id: pipeline.id,
+ format: :json
+ end
+
+ it 'cancels a pipeline without returning any content' do
+ expect(response).to have_http_status(:no_content)
+ expect(pipeline.reload).to be_canceled
+ end
+ end
end