Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLin Jen-Shin <godfat@godfat.org>2016-07-12 18:15:08 +0300
committerLin Jen-Shin <godfat@godfat.org>2016-07-12 18:15:08 +0300
commite383254070baf8a4701e3a10b7cc699f03cefff4 (patch)
tree5537a7c8f87f9f8277ad150ebc04814fc85b5e57 /spec/requests/projects
parenta96e9aa0d3f703e61a415d2b0532f3a96d90ba51 (diff)
Add all the tests and fix stuffs along the way:
It turns out they are different: builds.success.latest.first and builds.latest.success.first If we put success first, that latest would also filter via success, and which is what we want here.
Diffstat (limited to 'spec/requests/projects')
-rw-r--r--spec/requests/projects/artifacts_controller_spec.rb145
1 files changed, 145 insertions, 0 deletions
diff --git a/spec/requests/projects/artifacts_controller_spec.rb b/spec/requests/projects/artifacts_controller_spec.rb
new file mode 100644
index 00000000000..b11eb1aedcc
--- /dev/null
+++ b/spec/requests/projects/artifacts_controller_spec.rb
@@ -0,0 +1,145 @@
+require 'spec_helper'
+
+describe Projects::ArtifactsController do
+ let(:user) { create(:user) }
+ let(:project) { create(:project) }
+ let(:pipeline) do
+ create(:ci_pipeline, project: project, sha: project.commit('fix').sha)
+ end
+ let(:build) { create(:ci_build, :success, :artifacts, pipeline: pipeline) }
+
+ before do
+ login_as(user)
+ project.team << [user, :developer]
+ end
+
+ describe 'GET /:project/artifacts/:ref/:build_name/browse' do
+ context '404' do
+ it 'has no such ref' do
+ path = search_namespace_project_artifacts_path(
+ project.namespace,
+ project,
+ 'TAIL',
+ build.name,
+ 'browse')
+
+ get path
+
+ 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 'has no path' do
+ get search_namespace_project_artifacts_path(
+ project.namespace,
+ project,
+ pipeline.sha,
+ build.name,
+ '')
+
+ expect(response.status).to eq(404)
+ end
+ end
+
+ context '302' do
+ def path_from_sha
+ search_namespace_project_artifacts_path(
+ project.namespace,
+ project,
+ pipeline.sha,
+ 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_sha
+ 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 search_namespace_project_artifacts_path(
+ project.namespace,
+ project,
+ 'master',
+ build.name,
+ 'browse')
+ 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
+
+ before do
+ get search_namespace_project_artifacts_path(
+ project.namespace,
+ project,
+ 'improve/awesome',
+ build.name,
+ 'browse')
+ end
+
+ it_behaves_like 'redirect to the build'
+ 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_sha
+ 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_sha
+ end
+
+ it_behaves_like 'redirect to the build'
+ end
+ end
+ end
+end