diff options
author | Kamil Trzcinski <ayufan@ayufan.eu> | 2017-07-21 20:13:41 +0200 |
---|---|---|
committer | Kamil Trzcinski <ayufan@ayufan.eu> | 2017-07-22 15:07:52 +0200 |
commit | 0711d9adfc9e402c7763ce1ce914bc672165eb90 (patch) | |
tree | 54bedc855125771c805da6ca495de18d1a89337a /spec/requests | |
parent | 8efc8841665471403de93b431cbbe66004446c2e (diff) | |
download | gitlab-ce-0711d9adfc9e402c7763ce1ce914bc672165eb90.tar.gz |
Fix support for old CI API when image or services are not specifiedfix-old-ci-api
Diffstat (limited to 'spec/requests')
-rw-r--r-- | spec/requests/ci/api/builds_spec.rb | 66 |
1 files changed, 66 insertions, 0 deletions
diff --git a/spec/requests/ci/api/builds_spec.rb b/spec/requests/ci/api/builds_spec.rb index c969d08d0dd..49e815ee16c 100644 --- a/spec/requests/ci/api/builds_spec.rb +++ b/spec/requests/ci/api/builds_spec.rb @@ -69,6 +69,72 @@ describe Ci::API::Builds do end end + context 'when an old image syntax is used' do + before do + build.update!(options: { image: 'codeclimate' }) + end + + it 'starts a build' do + register_builds info: { platform: :darwin } + + expect(response).to have_http_status(201) + expect(json_response["options"]).to eq({ "image" => "codeclimate" }) + end + end + + context 'when a new image syntax is used' do + before do + build.update!(options: { image: { name: 'codeclimate' } }) + end + + it 'starts a build' do + register_builds info: { platform: :darwin } + + expect(response).to have_http_status(201) + expect(json_response["options"]).to eq({ "image" => "codeclimate" }) + end + end + + context 'when an old service syntax is used' do + before do + build.update!(options: { services: ['mysql'] }) + end + + it 'starts a build' do + register_builds info: { platform: :darwin } + + expect(response).to have_http_status(201) + expect(json_response["options"]).to eq({ "services" => ["mysql"] }) + end + end + + context 'when a new service syntax is used' do + before do + build.update!(options: { services: [name: 'mysql'] }) + end + + it 'starts a build' do + register_builds info: { platform: :darwin } + + expect(response).to have_http_status(201) + expect(json_response["options"]).to eq({ "services" => ["mysql"] }) + end + end + + context 'when no image or service is defined' do + before do + build.update!(options: {}) + end + + it 'starts a build' do + register_builds info: { platform: :darwin } + + expect(response).to have_http_status(201) + + expect(json_response["options"]).to be_empty + end + end + context 'when there is a pending build' do it 'starts a build' do register_builds info: { platform: :darwin } |