diff options
author | Tomasz Maczukin <tomasz@maczukin.pl> | 2017-06-05 16:39:45 +0200 |
---|---|---|
committer | Tomasz Maczukin <tomasz@maczukin.pl> | 2017-06-12 12:58:35 +0200 |
commit | b7d6bb9763ce0c682fae787c452103102624da26 (patch) | |
tree | e84543bbac2a2bd339b9b38b56e1746086d94455 | |
parent | c70e9f2ed107ac3d0189a803eae6e7e7917f6224 (diff) | |
download | gitlab-ce-b7d6bb9763ce0c682fae787c452103102624da26.tar.gz |
Ensure that old API v1 generates still the same output
-rw-r--r-- | lib/ci/api/entities.rb | 20 | ||||
-rw-r--r-- | spec/requests/ci/api/builds_spec.rb | 12 |
2 files changed, 31 insertions, 1 deletions
diff --git a/lib/ci/api/entities.rb b/lib/ci/api/entities.rb index 792ff628b09..6733d1a33aa 100644 --- a/lib/ci/api/entities.rb +++ b/lib/ci/api/entities.rb @@ -45,7 +45,25 @@ module Ci expose :artifacts_expire_at, if: ->(build, _) { build.artifacts? } expose :options do |model| - model.options + options = model.options + + # This part ensures that output of old API is still the same after adding support + # for extended docker configuration options, used by new API + # + # I'm leaving this here, not in the model, because it should be removed at the same time + # when old API will be removed (planned for August 2017). + options[:image] = options[:image][:name] if options[:image].present? && options[:image].is_a?(Hash) + if options[:services].present? + options[:services].map! do |service| + if service.is_a?(Hash) + service[:name] + else + service + end + end + end + + options end expose :timeout do |model| diff --git a/spec/requests/ci/api/builds_spec.rb b/spec/requests/ci/api/builds_spec.rb index 286de277ae7..04cc7708858 100644 --- a/spec/requests/ci/api/builds_spec.rb +++ b/spec/requests/ci/api/builds_spec.rb @@ -137,6 +137,18 @@ describe Ci::API::Builds do end end end + + context 'when docker configuration options are used' do + let!(:build) { create(:ci_build, :extended_options, pipeline: pipeline, name: 'spinach', stage: 'test', stage_idx: 0) } + + it 'starts a build' do + register_builds info: { platform: :darwin } + + expect(response).to have_http_status(201) + expect(json_response['options']['image']).to eq('ruby:2.1') + expect(json_response['options']['services']).to eq(['postgres', 'docker:dind']) + end + end end context 'when builds are finished' do |