summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLin Jen-Shin <godfat@godfat.org>2016-06-28 16:46:16 +0800
committerLin Jen-Shin <godfat@godfat.org>2016-06-28 16:46:16 +0800
commitaa3a3fd12fc7152020ffbe54faa36a4f17eb94b2 (patch)
treefbb57bf37629750c874e8c4c3600c3eff873f1af
parentc9a46263336dd38aef90b71995e2790be72d441d (diff)
downloadgitlab-ce-aa3a3fd12fc7152020ffbe54faa36a4f17eb94b2.tar.gz
Cleanup the tests a bit in order to extend it
-rw-r--r--spec/requests/ci/api/builds_spec.rb49
1 files changed, 34 insertions, 15 deletions
diff --git a/spec/requests/ci/api/builds_spec.rb b/spec/requests/ci/api/builds_spec.rb
index 1bc51783c3a..ea984924701 100644
--- a/spec/requests/ci/api/builds_spec.rb
+++ b/spec/requests/ci/api/builds_spec.rb
@@ -295,31 +295,50 @@ describe Ci::API::API do
context 'build has been erased' do
let(:build) { create(:ci_build, erased_at: Time.now) }
- before { upload_artifacts(file_upload, headers_with_token) }
+
+ before do
+ upload_artifacts(file_upload, headers_with_token)
+ end
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)
- expect(response).to have_http_status(201)
- expect(json_response["artifacts_file"]["filename"]).to eq(file_upload.original_filename)
+ context 'should post artifact to running build' do
+ shared_examples 'post artifact' do
+ it 'updates successfully' do
+ response_filename =
+ json_response["artifacts_file"]["filename"]
+
+ expect(response).to have_http_status(201)
+ expect(response_filename).to eq(file_upload.original_filename)
+ end
+ end
+
+ context 'uses regular file post' do
+ before do
+ upload_artifacts(file_upload, headers_with_token, false)
+ end
+
+ it_behaves_like 'post artifact'
end
- it "uses accelerated file post" do
- upload_artifacts(file_upload, headers_with_token, true)
- expect(response).to have_http_status(201)
- expect(json_response["artifacts_file"]["filename"]).to eq(file_upload.original_filename)
+ context 'uses accelerated file post' do
+ before do
+ upload_artifacts(file_upload, headers_with_token, true)
+ end
+
+ it_behaves_like 'post artifact'
end
- it "updates artifact" do
- upload_artifacts(file_upload, headers_with_token)
- upload_artifacts(file_upload2, headers_with_token)
- expect(response).to have_http_status(201)
- expect(json_response["artifacts_file"]["filename"]).to eq(file_upload2.original_filename)
+ context 'updates artifact' do
+ before do
+ upload_artifacts(file_upload2, headers_with_token)
+ upload_artifacts(file_upload, headers_with_token)
+ end
+
+ it_behaves_like 'post artifact'
end
end