diff options
author | Rémy Coutable <remy@rymai.me> | 2016-11-21 11:30:23 +0000 |
---|---|---|
committer | Rémy Coutable <remy@rymai.me> | 2016-11-21 11:30:23 +0000 |
commit | c99522f21eed933f6a6b7214ea659e3ab13ef188 (patch) | |
tree | 782908e4dcd1f33468e583d4e2d56a3aab2706b9 /spec | |
parent | b98193c55edc94b3ecf1ff143ac85fa9e9d8f029 (diff) | |
parent | fbfc7523cb0119ac3a0d02cd04dc12e453ad3ad6 (diff) | |
download | gitlab-ce-c99522f21eed933f6a6b7214ea659e3ab13ef188.tar.gz |
Merge branch 'create-pipeline-endpoint' into 'master'
Add API endpoint for creating a pipeline
Fixes #23468
See merge request !7209
Diffstat (limited to 'spec')
-rw-r--r-- | spec/requests/api/pipelines_spec.rb | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/spec/requests/api/pipelines_spec.rb b/spec/requests/api/pipelines_spec.rb index 7011bdc9ec0..d83f7883c78 100644 --- a/spec/requests/api/pipelines_spec.rb +++ b/spec/requests/api/pipelines_spec.rb @@ -41,6 +41,52 @@ describe API::API, api: true do end end + describe 'POST /projects/:id/pipeline ' do + context 'authorized user' do + context 'with gitlab-ci.yml' do + before { stub_ci_pipeline_to_return_yaml_file } + + it 'creates and returns a new pipeline' do + expect do + post api("/projects/#{project.id}/pipeline", user), ref: project.default_branch + end.to change { Ci::Pipeline.count }.by(1) + + expect(response).to have_http_status(201) + expect(json_response).to be_a Hash + expect(json_response['sha']).to eq project.commit.id + end + + it 'fails when using an invalid ref' do + post api("/projects/#{project.id}/pipeline", user), ref: 'invalid_ref' + + expect(response).to have_http_status(400) + expect(json_response['message']['base'].first).to eq 'Reference not found' + expect(json_response).not_to be_an Array + end + end + + context 'without gitlab-ci.yml' do + it 'fails to create pipeline' do + post api("/projects/#{project.id}/pipeline", user), ref: project.default_branch + + expect(response).to have_http_status(400) + expect(json_response['message']['base'].first).to eq 'Missing .gitlab-ci.yml file' + expect(json_response).not_to be_an Array + end + end + end + + context 'unauthorized user' do + it 'does not create pipeline' do + post api("/projects/#{project.id}/pipeline", non_member), ref: project.default_branch + + expect(response).to have_http_status(404) + expect(json_response['message']).to eq '404 Project Not Found' + expect(json_response).not_to be_an Array + end + end + end + describe 'GET /projects/:id/pipelines/:pipeline_id' do context 'authorized user' do it 'returns project pipelines' do |