diff options
author | Tomasz Maczukin <tomasz@maczukin.pl> | 2017-03-16 14:45:05 +0100 |
---|---|---|
committer | Kamil Trzcinski <ayufan@ayufan.eu> | 2017-03-20 09:40:36 +0100 |
commit | c191c1103b37903f2293c2a662cdc616228b9eb7 (patch) | |
tree | db984310faca38cef2d283d0a9746f229a6dc6c1 /spec/requests/api/runner_spec.rb | |
parent | 9267a9b19d6c7e090c286e9d922c71fe64190a47 (diff) | |
download | gitlab-ce-c191c1103b37903f2293c2a662cdc616228b9eb7.tar.gz |
Send only defined dependencies
In APIv1 we've been sending all jobs from previous stages and
a `dependencies` list with names of jobs that user want to download
artifacts from. This was selected on Runners side.
In APIv1 we've planned to send only jobs that were defined (if any; and
all previous jobs by default). However I've missed the fact that
it was Runner who selected jobs, not GitLab. And now current version
of APIV4 sends all jobs everytime.
This commit fixes this. If user will define `dependencies` in his job,
then GitLab will send only selected jobs.
Diffstat (limited to 'spec/requests/api/runner_spec.rb')
-rw-r--r-- | spec/requests/api/runner_spec.rb | 37 |
1 files changed, 33 insertions, 4 deletions
diff --git a/spec/requests/api/runner_spec.rb b/spec/requests/api/runner_spec.rb index 76461aabd9a..d4d6ac51c03 100644 --- a/spec/requests/api/runner_spec.rb +++ b/spec/requests/api/runner_spec.rb @@ -417,10 +417,39 @@ describe API::Runner do end context 'when project and pipeline have multiple jobs' do - let!(:job) { create(:ci_build_tag, pipeline: pipeline, token: 'job-token', name: 'spinach', stage: 'test', stage_idx: 0) } - let!(:test_job) { create(:ci_build, pipeline: pipeline, token: 'test-job-token', name: 'deploy', stage: 'deploy', stage_idx: 1) } + let!(:job) { create(:ci_build_tag, pipeline: pipeline, name: 'spinach', stage: 'test', stage_idx: 0) } + let!(:job2) { create(:ci_build_tag, pipeline: pipeline, name: 'rubocop', stage: 'test', stage_idx: 0) } + let!(:test_job) { create(:ci_build, pipeline: pipeline, name: 'deploy', stage: 'deploy', stage_idx: 1) } - before { job.success } + before do + job.success + job2.success + end + + it 'returns dependent jobs' do + request_job + + expect(response).to have_http_status(201) + expect(json_response['id']).to eq(test_job.id) + expect(json_response['dependencies'].count).to eq(2) + expect(json_response['dependencies']).to include({ 'id' => job.id, 'name' => job.name, 'token' => job.token }, + { 'id' => job2.id, 'name' => job2.name, 'token' => job2.token }) + end + end + + context 'when explicit dependencies are defined' do + let!(:job) { create(:ci_build_tag, pipeline: pipeline, name: 'spinach', stage: 'test', stage_idx: 0) } + let!(:job2) { create(:ci_build_tag, pipeline: pipeline, name: 'rubocop', stage: 'test', stage_idx: 0) } + let!(:test_job) do + create(:ci_build, pipeline: pipeline, token: 'test-job-token', name: 'deploy', + stage: 'deploy', stage_idx: 1, + options: { dependencies: [job2.name] }) + end + + before do + job.success + job2.success + end it 'returns dependent jobs' do request_job @@ -428,7 +457,7 @@ describe API::Runner do expect(response).to have_http_status(201) expect(json_response['id']).to eq(test_job.id) expect(json_response['dependencies'].count).to eq(1) - expect(json_response['dependencies'][0]).to include('id' => job.id, 'name' => 'spinach', 'token' => job.token) + expect(json_response['dependencies'][0]).to include('id' => job2.id, 'name' => job2.name, 'token' => job2.token) end end |