Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
f94df424
Commit
f94df424
authored
Dec 26, 2017
by
Lin Jen-Shin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Just use the tests from EE
parent
29749f92
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
34 additions
and
13 deletions
+34
-13
spec/controllers/projects/artifacts_controller_spec.rb
spec/controllers/projects/artifacts_controller_spec.rb
+34
-13
No files found.
spec/controllers/projects/artifacts_controller_spec.rb
View file @
f94df424
require
'spec_helper'
describe
Projects
::
ArtifactsController
do
set
(
:user
)
{
create
(
:user
)
}
let
(
:user
)
{
project
.
owner
}
set
(
:project
)
{
create
(
:project
,
:repository
,
:public
)
}
let
(
:pipeline
)
do
...
...
@@ -15,14 +15,12 @@ describe Projects::ArtifactsController do
let
(
:job
)
{
create
(
:ci_build
,
:success
,
:artifacts
,
pipeline:
pipeline
)
}
before
do
project
.
add_developer
(
user
)
sign_in
(
user
)
end
describe
'GET download'
do
it
'sends the artifacts file'
do
expect
(
controller
).
to
receive
(
:send_file
).
with
(
job
.
artifacts_file
.
path
,
disposition:
'attachment'
).
and_call_original
expect
(
controller
).
to
receive
(
:send_file
).
with
(
job
.
artifacts_file
.
path
,
hash_including
(
disposition:
'attachment'
)
).
and_call_original
get
:download
,
namespace_id:
project
.
namespace
,
project_id:
project
,
job_id:
job
end
...
...
@@ -113,20 +111,43 @@ describe Projects::ArtifactsController do
end
describe
'GET raw'
do
subject
{
get
(
:raw
,
namespace_id:
project
.
namespace
,
project_id:
project
,
job_id:
job
,
path:
path
)
}
context
'when the file exists'
do
it
'serves the file using workhorse'
do
get
:raw
,
namespace_id:
project
.
namespace
,
project_id:
project
,
job_id:
job
,
path:
'ci_artifacts.txt'
let
(
:path
)
{
'ci_artifacts.txt'
}
send_data
=
response
.
headers
[
Gitlab
::
Workhorse
::
SEND_DATA_HEADER
]
shared_examples
'a valid file'
do
it
'serves the file using workhorse'
do
subject
expect
(
send_data
).
to
start_with
(
'artifacts-entry:'
)
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
send_data
).
to
start_with
(
'artifacts-entry:'
)
base64_params
=
send_data
.
sub
(
/\Aartifacts\-entry:/
,
''
)
params
=
JSON
.
parse
(
Base64
.
urlsafe_decode64
(
base64_params
))
expect
(
params
.
keys
).
to
eq
(
%w(Archive Entry)
)
expect
(
params
[
'Archive'
]).
to
start_with
(
archive_path
)
# On object storage, the URL can end with a query string
expect
(
params
[
'Archive'
]).
to
match
(
/build_artifacts.zip(\?[^?]+)?$/
)
expect
(
params
[
'Entry'
]).
to
eq
(
Base64
.
encode64
(
'ci_artifacts.txt'
))
end
def
send_data
response
.
headers
[
Gitlab
::
Workhorse
::
SEND_DATA_HEADER
]
end
expect
(
params
.
keys
).
to
eq
(
%w(Archive Entry)
)
expect
(
params
[
'Archive'
]).
to
end_with
(
'build_artifacts.zip'
)
expect
(
params
[
'Entry'
]).
to
eq
(
Base64
.
encode64
(
'ci_artifacts.txt'
))
def
params
@params
||=
begin
base64_params
=
send_data
.
sub
(
/\Aartifacts\-entry:/
,
''
)
JSON
.
parse
(
Base64
.
urlsafe_decode64
(
base64_params
))
end
end
end
context
'when using local file storage'
do
it_behaves_like
'a valid file'
do
let
(
:job
)
{
create
(
:ci_build
,
:success
,
:artifacts
,
pipeline:
pipeline
)
}
let
(
:store
)
{
ObjectStoreUploader
::
LOCAL_STORE
}
let
(
:archive_path
)
{
JobArtifactUploader
.
local_store_path
}
end
end
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