BigW Consortium Gitlab
Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gitlab-ce
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Forest Godfrey
gitlab-ce
Commits
fa02d8fc
Commit
fa02d8fc
authored
Jul 21, 2016
by
Lin Jen-Shin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Merge shared context into controller test and update accordingly
parent
69d06713
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
57 additions
and
111 deletions
+57
-111
artifacts_controller_spec.rb
spec/requests/projects/artifacts_controller_spec.rb
+57
-10
artifacts_context.rb
spec/requests/shared/artifacts_context.rb
+0
-101
No files found.
spec/requests/projects/artifacts_controller_spec.rb
View file @
fa02d8fc
require
'spec_helper'
require
'spec_helper'
require_relative
'../shared/artifacts_context'
describe
Projects
::
ArtifactsController
do
describe
Projects
::
ArtifactsController
do
let
(
:user
)
{
create
(
:user
)
}
let
(
:project
)
{
create
(
:project
)
}
let
(
:pipeline
)
do
create
(
:ci_pipeline
,
project:
project
,
sha:
project
.
commit
.
sha
,
ref:
project
.
default_branch
)
end
let
(
:build
)
{
create
(
:ci_build
,
:success
,
:artifacts
,
pipeline:
pipeline
)
}
describe
'GET /:project/builds/artifacts/:ref_name/browse?job=name'
do
describe
'GET /:project/builds/artifacts/:ref_name/browse?job=name'
do
include_context
'artifacts from ref and build name'
before
do
project
.
team
<<
[
user
,
:developer
]
end
before
do
before
do
login_as
(
user
)
login_as
(
user
)
...
@@ -19,24 +30,39 @@ describe Projects::ArtifactsController do
...
@@ -19,24 +30,39 @@ describe Projects::ArtifactsController do
job:
job
)
job:
job
)
end
end
context
'404'
do
context
'cannot find the build'
do
def
verify
shared_examples
'not found'
do
expect
(
response
.
status
).
to
eq
(
404
)
it
{
expect
(
response
).
to
have_http_status
(
:not_found
)
}
end
context
'has no such ref'
do
before
do
get
path_from_ref
(
'TAIL'
,
build
.
name
)
end
end
it_behaves_like
'artifacts from ref with 404'
it_behaves_like
'not found'
end
context
'has no such build'
do
before
do
get
path_from_ref
(
pipeline
.
ref
,
'NOBUILD'
)
end
it_behaves_like
'not found'
end
context
'has no path'
do
context
'has no path'
do
before
do
before
do
get
path_from_ref
(
pipeline
.
sha
,
build
.
name
,
''
)
get
path_from_ref
(
pipeline
.
sha
,
build
.
name
,
''
)
end
end
it
(
'gives 404'
)
{
verify
}
it
_behaves_like
'not found'
end
end
end
end
context
'302'
do
context
'found the build and redirect'
do
def
verify
shared_examples
'redirect to the build'
do
it
'redirects'
do
path
=
browse_namespace_project_build_artifacts_path
(
path
=
browse_namespace_project_build_artifacts_path
(
project
.
namespace
,
project
.
namespace
,
project
,
project
,
...
@@ -44,8 +70,29 @@ describe Projects::ArtifactsController do
...
@@ -44,8 +70,29 @@ describe Projects::ArtifactsController do
expect
(
response
).
to
redirect_to
(
path
)
expect
(
response
).
to
redirect_to
(
path
)
end
end
end
context
'with regular branch'
do
before
do
pipeline
.
update
(
ref:
'master'
,
sha:
project
.
commit
(
'master'
).
sha
)
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
(
ref:
'improve/awesome'
,
sha:
project
.
commit
(
'improve/awesome'
).
sha
)
it_behaves_like
'artifacts from ref successfully'
get
path_from_ref
(
'improve/awesome'
)
end
it_behaves_like
'redirect to the build'
end
end
end
end
end
end
end
spec/requests/shared/artifacts_context.rb
deleted
100644 → 0
View file @
69d06713
shared_context
'artifacts from ref and build name'
do
let
(
:user
)
{
create
(
:user
)
}
let
(
:project
)
{
create
(
:project
)
}
let
(
:pipeline
)
do
create
(
:ci_pipeline
,
project:
project
,
sha:
project
.
commit
(
'fix'
).
sha
,
ref:
'fix'
)
end
let
(
:build
)
{
create
(
:ci_build
,
:success
,
:artifacts
,
pipeline:
pipeline
)
}
before
do
project
.
team
<<
[
user
,
:developer
]
end
end
shared_examples
'artifacts from ref with 404'
do
context
'has no such ref'
do
before
do
get
path_from_ref
(
'TAIL'
,
build
.
name
)
end
it
(
'gives 404'
)
{
verify
}
end
context
'has no such build'
do
before
do
get
path_from_ref
(
pipeline
.
ref
,
'NOBUILD'
)
end
it
(
'gives 404'
)
{
verify
}
end
end
shared_examples
'artifacts from ref successfully'
do
def
create_new_pipeline
(
status
)
new_pipeline
=
create
(
:ci_pipeline
,
status:
'success'
)
create
(
:ci_build
,
status
,
:artifacts
,
pipeline:
new_pipeline
)
end
context
'with sha'
do
before
do
get
path_from_ref
(
pipeline
.
sha
)
end
it
(
'gives the file'
)
{
verify
}
end
context
'with regular branch'
do
before
do
pipeline
.
update
(
ref:
'master'
,
sha:
project
.
commit
(
'master'
).
sha
)
end
before
do
get
path_from_ref
(
'master'
)
end
it
(
'gives the file'
)
{
verify
}
end
context
'with branch name containing slash'
do
before
do
pipeline
.
update
(
ref:
'improve/awesome'
,
sha:
project
.
commit
(
'improve/awesome'
).
sha
)
end
before
do
get
path_from_ref
(
'improve/awesome'
)
end
it
(
'gives the file'
)
{
verify
}
end
context
'with latest pipeline'
do
before
do
3
.
times
do
# creating some old pipelines
create_new_pipeline
(
:success
)
end
end
before
do
get
path_from_ref
end
it
(
'gives the file'
)
{
verify
}
end
context
'with success pipeline'
do
before
do
build
# make sure pipeline was old, but still the latest success one
create_new_pipeline
(
:pending
)
end
before
do
get
path_from_ref
end
it
(
'gives the file'
)
{
verify
}
end
end
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment