From 7fe14c42a913c683bd6f7c4f8791fff63db3c499 Mon Sep 17 00:00:00 2001 From: Shinya Maeda Date: Tue, 2 Oct 2018 18:47:41 +0900 Subject: Add integration spec --- spec/controllers/projects/jobs_controller_spec.rb | 40 +++++++++++++++++++++++ 1 file changed, 40 insertions(+) (limited to 'spec/controllers') diff --git a/spec/controllers/projects/jobs_controller_spec.rb b/spec/controllers/projects/jobs_controller_spec.rb index fd11cb31a2a..f1eefdbaaaf 100644 --- a/spec/controllers/projects/jobs_controller_spec.rb +++ b/spec/controllers/projects/jobs_controller_spec.rb @@ -632,6 +632,46 @@ describe Projects::JobsController, :clean_gitlab_redis_shared_state do end end + describe 'POST unschedule' do + before do + project.add_developer(user) + + create(:protected_branch, :developers_can_merge, + name: 'master', project: project) + + sign_in(user) + + post_unschedule + end + + context 'when job is scheduled' do + let(:job) { create(:ci_build, :scheduled, pipeline: pipeline) } + + it 'redirects to the unscheduled job page' do + expect(response).to have_gitlab_http_status(:found) + expect(response).to redirect_to(namespace_project_job_path(id: job.id)) + end + + it 'transits to manual' do + expect(job.reload).to be_manual + end + end + + context 'when job is not scheduled' do + let(:job) { create(:ci_build, pipeline: pipeline) } + + it 'renders unprocessable_entity' do + expect(response).to have_gitlab_http_status(:unprocessable_entity) + end + end + + def post_unschedule + post :unschedule, namespace_id: project.namespace, + project_id: project, + id: job.id + end + end + describe 'POST cancel_all' do before do project.add_developer(user) -- cgit v1.2.1