diff options
| author | Grzegorz Bizon <grzegorz.bizon@ntsn.pl> | 2016-02-03 12:55:08 +0100 |
|---|---|---|
| committer | Grzegorz Bizon <grzesiek.bizon@gmail.com> | 2016-02-19 17:24:59 +0100 |
| commit | df313634d0e247fb39726dc3b070c707100275ed (patch) | |
| tree | 8eb2d307058e1dc5b8507d9d74ced51146f37337 /spec/requests | |
| parent | 21152d7d51815622fd3cbb93836cb8fa7b753ec8 (diff) | |
| download | gitlab-ce-df313634d0e247fb39726dc3b070c707100275ed.tar.gz | |
Do not allow to modify build if it has been erased
Diffstat (limited to 'spec/requests')
| -rw-r--r-- | spec/requests/ci/api/builds_spec.rb | 56 |
1 files changed, 35 insertions, 21 deletions
diff --git a/spec/requests/ci/api/builds_spec.rb b/spec/requests/ci/api/builds_spec.rb index e1042bde8d5..4246ff38fa2 100644 --- a/spec/requests/ci/api/builds_spec.rb +++ b/spec/requests/ci/api/builds_spec.rb @@ -131,39 +131,41 @@ describe Ci::API::API do end describe "PUT /builds/:id" do - let(:commit) { FactoryGirl.create(:ci_commit, project: project)} - let(:build) { FactoryGirl.create(:ci_build, commit: commit, runner_id: runner.id) } + let(:commit) {create(:ci_commit, project: project)} + let(:build) { create(:ci_build_with_trace, commit: commit, runner_id: runner.id) } - it "should update a running build" do + before do build.run! put ci_api("/builds/#{build.id}"), token: runner.token + end + + it "should update a running build" do expect(response.status).to eq(200) end - it 'Should not override trace information when no trace is given' do - build.run! - build.update!(trace: 'hello_world') - put ci_api("/builds/#{build.id}"), token: runner.token - expect(build.reload.trace).to eq 'hello_world' + it 'should not override trace information when no trace is given' do + expect(build.reload.trace).to eq 'BUILD TRACE' + end + + context 'build has been erased' do + let(:build) { create(:ci_build, runner_id: runner.id, erased_at: Time.now) } + + it 'should respond with forbidden' do + expect(response.status).to eq 403 + end end end describe 'DELETE /builds/:id/content' do + let(:build) { create(:ci_build_with_trace, :artifacts, :success) } before { delete ci_api("/builds/#{build.id}/content"), token: build.token } - let!(:build) { create(:ci_build_with_trace, :artifacts, :success) } - it 'should respond with valid status' do + it 'should erase build content' do expect(response.status).to eq 200 - end - - it 'should remove build artifacts' do + expect(build.trace).to be_empty expect(build.artifacts_file.exists?).to be_falsy expect(build.artifacts_metadata.exists?).to be_falsy end - - it 'should remove build trace' do - expect(build.trace).to be_empty - end end context "Artifacts" do @@ -209,9 +211,10 @@ describe Ci::API::API do end end - context 'token is invalid' do - it 'should respond with forbidden'do - post authorize_url, { token: 'invalid', filesize: 100 } + context 'authorization token is invalid' do + before { post authorize_url, { token: 'invalid', filesize: 100 } } + + it 'should respond with forbidden' do expect(response.status).to eq(403) end end @@ -224,6 +227,15 @@ describe Ci::API::API do allow(ArtifactUploader).to receive(:artifacts_upload_path).and_return('/') end + context 'build has been erased' do + let(:build) { create(:ci_build, erased_at: Time.now) } + before { upload_artifacts(file_upload, headers_with_token) } + + it 'should respond with forbidden' do + expect(response.status).to eq 403 + end + end + context "should post artifact to running build" do it "uses regual file post" do upload_artifacts(file_upload, headers_with_token, false) @@ -252,7 +264,9 @@ describe Ci::API::API do let(:stored_artifacts_file) { build.reload.artifacts_file.file } let(:stored_metadata_file) { build.reload.artifacts_metadata.file } - before { post(post_url, post_data, headers_with_token) } + before do + post(post_url, post_data, headers_with_token) + end context 'post data accelerated by workhorse is correct' do let(:post_data) do |
