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
1db1dfa2
Commit
1db1dfa2
authored
Apr 05, 2017
by
Douglas Barbosa Alexandre
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add examples for other object types on the Geo API spec
parent
5933cd1b
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
74 additions
and
1 deletion
+74
-1
spec/requests/api/geo_spec.rb
spec/requests/api/geo_spec.rb
+74
-1
No files found.
spec/requests/api/geo_spec.rb
View file @
1db1dfa2
...
...
@@ -127,11 +127,47 @@ describe API::Geo, api: true do
end
end
describe
'GET /geo/transfers/attachment/1'
do
let!
(
:secondary_node
)
{
create
(
:geo_node
)
}
let
(
:note
)
{
create
(
:note
,
:with_attachment
)
}
let
(
:upload
)
{
Upload
.
find_by
(
model:
note
,
uploader:
'AttachmentUploader'
)
}
let
(
:transfer
)
{
Gitlab
::
Geo
::
FileTransfer
.
new
(
:attachment
,
upload
)
}
let
(
:req_header
)
{
Gitlab
::
Geo
::
TransferRequest
.
new
(
transfer
.
request_data
).
headers
}
before
do
allow_any_instance_of
(
Gitlab
::
Geo
::
TransferRequest
).
to
receive
(
:requesting_node
).
and_return
(
secondary_node
)
end
it
'responds with 401 with invalid auth header'
do
get
api
(
"/geo/transfers/attachment/
#{
upload
.
id
}
"
),
nil
,
Authorization
:
'Test'
expect
(
response
).
to
have_http_status
(
401
)
end
context
'attachment file exists'
do
it
'responds with 200 with X-Sendfile'
do
get
api
(
"/geo/transfers/attachment/
#{
upload
.
id
}
"
),
nil
,
req_header
expect
(
response
).
to
have_http_status
(
200
)
expect
(
response
.
headers
[
'Content-Type'
]).
to
eq
(
'application/octet-stream'
)
expect
(
response
.
headers
[
'X-Sendfile'
]).
to
eq
(
note
.
attachment
.
path
)
end
end
context
'attachment does not exist'
do
it
'responds with 404'
do
get
api
(
"/geo/transfers/attachment/100000"
),
nil
,
req_header
expect
(
response
).
to
have_http_status
(
404
)
end
end
end
describe
'GET /geo/transfers/avatar/1'
do
let!
(
:secondary_node
)
{
create
(
:geo_node
)
}
let
(
:user
)
{
create
(
:user
,
avatar:
fixture_file_upload
(
Rails
.
root
+
'spec/fixtures/dk.png'
,
'image/png'
))
}
let
(
:upload
)
{
Upload
.
find_by
(
model:
user
,
uploader:
'AvatarUploader'
)
}
let
(
:transfer
)
{
Gitlab
::
Geo
::
FileTransfer
.
new
(
upload
)
}
let
(
:transfer
)
{
Gitlab
::
Geo
::
FileTransfer
.
new
(
:avatar
,
upload
)
}
let
(
:req_header
)
{
Gitlab
::
Geo
::
TransferRequest
.
new
(
transfer
.
request_data
).
headers
}
before
do
...
...
@@ -163,6 +199,43 @@ describe API::Geo, api: true do
end
end
describe
'GET /geo/transfers/file/1'
do
let!
(
:secondary_node
)
{
create
(
:geo_node
)
}
let
(
:project
)
{
create
(
:empty_project
)
}
let
(
:upload
)
{
Upload
.
find_by
(
model:
project
,
uploader:
'FileUploader'
)
}
let
(
:transfer
)
{
Gitlab
::
Geo
::
FileTransfer
.
new
(
:file
,
upload
)
}
let
(
:req_header
)
{
Gitlab
::
Geo
::
TransferRequest
.
new
(
transfer
.
request_data
).
headers
}
before
do
allow_any_instance_of
(
Gitlab
::
Geo
::
TransferRequest
).
to
receive
(
:requesting_node
).
and_return
(
secondary_node
)
FileUploader
.
new
(
project
).
store!
(
fixture_file_upload
(
Rails
.
root
+
'spec/fixtures/dk.png'
,
'image/png'
))
end
it
'responds with 401 with invalid auth header'
do
get
api
(
"/geo/transfers/file/
#{
upload
.
id
}
"
),
nil
,
Authorization
:
'Test'
expect
(
response
).
to
have_http_status
(
401
)
end
context
'file file exists'
do
it
'responds with 200 with X-Sendfile'
do
get
api
(
"/geo/transfers/file/
#{
upload
.
id
}
"
),
nil
,
req_header
expect
(
response
).
to
have_http_status
(
200
)
expect
(
response
.
headers
[
'Content-Type'
]).
to
eq
(
'application/octet-stream'
)
expect
(
response
.
headers
[
'X-Sendfile'
]).
to
end_with
(
'dk.png'
)
end
end
context
'file does not exist'
do
it
'responds with 404'
do
get
api
(
"/geo/transfers/file/100000"
),
nil
,
req_header
expect
(
response
).
to
have_http_status
(
404
)
end
end
end
describe
'GET /geo/transfers/lfs/1'
do
let!
(
:secondary_node
)
{
create
(
:geo_node
)
}
let
(
:lfs_object
)
{
create
(
:lfs_object
,
:with_file
)
}
...
...
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