summaryrefslogtreecommitdiff
path: root/spec/requests/projects
diff options
context:
space:
mode:
authorLin Jen-Shin <godfat@godfat.org>2016-07-13 23:05:57 +0800
committerLin Jen-Shin <godfat@godfat.org>2016-07-13 23:07:37 +0800
commit8735d95af16a6066e9f256a62f401d02c2c7e108 (patch)
tree1db12ea4a925060965231a574a549460c3f901c9 /spec/requests/projects
parent6c80b597f58aaaca514e45a7e83b811db301e651 (diff)
downloadgitlab-ce-8735d95af16a6066e9f256a62f401d02c2c7e108.tar.gz
Implement API for downloading artifacts from ref and build name:
Basically: GET /api/projects/:id/artifacts/:ref_name/:build_name Also added tests for it.
Diffstat (limited to 'spec/requests/projects')
-rw-r--r--spec/requests/projects/artifacts_controller_spec.rb122
1 files changed, 23 insertions, 99 deletions
diff --git a/spec/requests/projects/artifacts_controller_spec.rb b/spec/requests/projects/artifacts_controller_spec.rb
index 4c4bacfcbda..9722a9a1d64 100644
--- a/spec/requests/projects/artifacts_controller_spec.rb
+++ b/spec/requests/projects/artifacts_controller_spec.rb
@@ -1,4 +1,5 @@
require 'spec_helper'
+require_relative '../shared/artifacts_context'
describe Projects::ArtifactsController do
let(:user) { create(:user) }
@@ -14,120 +15,43 @@ describe Projects::ArtifactsController do
end
describe 'GET /:project/artifacts/:ref/:build_name/browse' do
- context '404' do
- it 'has no such ref' do
- get search_namespace_project_artifacts_path(
- project.namespace,
- project,
- 'TAIL',
- build.name,
- 'browse')
+ def path_from_ref(ref = pipeline.sha, build_name = build.name,
+ path = 'browse')
+ search_namespace_project_artifacts_path(
+ project.namespace,
+ project,
+ ref,
+ build_name,
+ path)
+ end
+ context '404' do
+ def verify
expect(response.status).to eq(404)
end
- it 'has no such build' do
- get search_namespace_project_artifacts_path(
- project.namespace,
- project,
- pipeline.sha,
- 'NOBUILD',
- 'browse')
-
- expect(response.status).to eq(404)
- end
+ it_behaves_like 'artifacts from ref with 404'
- it 'has no path' do
- get search_namespace_project_artifacts_path(
- project.namespace,
- project,
- pipeline.sha,
- build.name,
- '')
+ context 'has no path' do
+ before do
+ get path_from_ref(pipeline.sha, build.name, '')
+ end
- expect(response.status).to eq(404)
+ it('gives 404') { verify }
end
end
context '302' do
- def path_from_ref(ref = pipeline.sha, build_name = build.name)
- search_namespace_project_artifacts_path(
+ def verify
+ path = browse_namespace_project_build_artifacts_path(
project.namespace,
project,
- ref,
- build_name,
- 'browse')
- end
-
- shared_examples 'redirect to the build' do
- it 'redirects' do
- path = browse_namespace_project_build_artifacts_path(
- project.namespace,
- project,
- build)
-
- expect(response).to redirect_to(path)
- end
- end
-
- context 'with sha' do
- before do
- get path_from_ref
- end
-
- it_behaves_like 'redirect to the build'
- end
-
- context 'with regular branch' do
- before do
- pipeline.update(sha: project.commit('master').sha)
- end
-
- before do
- get path_from_ref('master')
- end
-
- it_behaves_like 'redirect to the build'
- end
-
- context 'with branch name containing slash' do
- before do
- pipeline.update(sha: project.commit('improve/awesome').sha)
- end
+ build)
- before do
- get path_from_ref('improve/awesome')
- end
-
- it_behaves_like 'redirect to the build'
+ expect(response).to redirect_to(path)
end
- context 'with latest build' do
- before do
- 3.times do # creating some old builds
- create(:ci_build, :success, :artifacts, pipeline: pipeline)
- end
- end
-
- before do
- get path_from_ref
- end
-
- it_behaves_like 'redirect to the build'
- end
-
- context 'with success build' do
- before do
- build # make sure build was old, but still the latest success one
- create(:ci_build, :pending, :artifacts, pipeline: pipeline)
- end
-
- before do
- get path_from_ref
- end
-
- it_behaves_like 'redirect to the build'
- end
+ it_behaves_like 'artifacts from ref with 302'
end
end
end