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
916c9e7b
Commit
916c9e7b
authored
Apr 04, 2017
by
Douglas Barbosa Alexandre
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Rename AvatarTransfer to FileTransfer
parent
053ff3ba
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
19 additions
and
17 deletions
+19
-17
app/services/geo/file_upload_service.rb
app/services/geo/file_upload_service.rb
+1
-1
lib/gitlab/geo/avatar_downloader.rb
lib/gitlab/geo/avatar_downloader.rb
+1
-1
lib/gitlab/geo/avatar_uploader.rb
lib/gitlab/geo/avatar_uploader.rb
+1
-1
lib/gitlab/geo/file_transfer.rb
lib/gitlab/geo/file_transfer.rb
+3
-3
lib/gitlab/geo/file_uploader.rb
lib/gitlab/geo/file_uploader.rb
+2
-0
spec/lib/gitlab/geo/avatar_downloader_spec.rb
spec/lib/gitlab/geo/avatar_downloader_spec.rb
+1
-1
spec/requests/api/geo_spec.rb
spec/requests/api/geo_spec.rb
+1
-1
spec/services/geo/file_download_service_spec.rb
spec/services/geo/file_download_service_spec.rb
+3
-3
spec/services/geo/file_upload_service_spec.rb
spec/services/geo/file_upload_service_spec.rb
+6
-6
No files found.
app/services/geo/file_upload_service.rb
View file @
916c9e7b
...
...
@@ -18,7 +18,7 @@ module Geo
begin
uploader_class
.
new
(
object_db_id
,
data
).
execute
rescue
NameError
log
(
"
u
nknown file type:
#{
object_type
}
"
)
log
(
"
U
nknown file type:
#{
object_type
}
"
)
{}
end
end
...
...
lib/gitlab/geo/avatar_downloader.rb
View file @
916c9e7b
...
...
@@ -5,7 +5,7 @@ module Gitlab
upload
=
Upload
.
find_by_id
(
object_db_id
)
return
unless
upload
.
present?
transfer
=
::
Gitlab
::
Geo
::
AvatarTransfer
.
new
(
upload
)
transfer
=
::
Gitlab
::
Geo
::
FileTransfer
.
new
(
:avatar
,
upload
)
transfer
.
download_from_primary
end
end
...
...
lib/gitlab/geo/avatar_uploader.rb
View file @
916c9e7b
...
...
@@ -2,7 +2,7 @@ module Gitlab
module
Geo
class
AvatarUploader
<
FileUploader
def
execute
upload
=
Upload
.
find
(
object_db_id
)
upload
=
Upload
.
find
_by_id
(
object_db_id
)
return
error
unless
upload
.
present?
return
error
unless
valid?
(
upload
)
...
...
lib/gitlab/geo/
avatar
_transfer.rb
→
lib/gitlab/geo/
file
_transfer.rb
View file @
916c9e7b
module
Gitlab
module
Geo
class
Avatar
Transfer
<
Transfer
def
initialize
(
upload
)
@file_type
=
:avatar
class
File
Transfer
<
Transfer
def
initialize
(
file_type
,
upload
)
@file_type
=
file_type
@file_id
=
upload
.
id
@filename
=
upload
.
path
@request_data
=
build_request_data
(
upload
)
...
...
lib/gitlab/geo/file_uploader.rb
View file @
916c9e7b
...
...
@@ -12,6 +12,8 @@ module Gitlab
raise
NotImplementedError
end
private
def
success
(
file
)
{
code: :ok
,
message:
'Success'
,
file:
file
}
end
...
...
spec/lib/gitlab/geo/avatar_downloader_spec.rb
View file @
916c9e7b
...
...
@@ -7,7 +7,7 @@ describe Gitlab::Geo::AvatarDownloader do
context
'#download_from_primary'
do
it
'downlods the avatar'
do
allow_any_instance_of
(
Gitlab
::
Geo
::
Avatar
Transfer
)
allow_any_instance_of
(
Gitlab
::
Geo
::
File
Transfer
)
.
to
receive
(
:download_from_primary
).
and_return
(
100
)
downloader
=
described_class
.
new
(
upload
.
id
)
...
...
spec/requests/api/geo_spec.rb
View file @
916c9e7b
...
...
@@ -125,7 +125,7 @@ describe API::Geo, api: true 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
::
Avatar
Transfer
.
new
(
upload
)
}
let
(
:transfer
)
{
Gitlab
::
Geo
::
File
Transfer
.
new
(
upload
)
}
let
(
:req_header
)
{
Gitlab
::
Geo
::
TransferRequest
.
new
(
transfer
.
request_data
).
headers
}
before
do
...
...
spec/services/geo/file_download_service_spec.rb
View file @
916c9e7b
...
...
@@ -18,7 +18,7 @@ describe Geo::FileDownloadService, services: true do
it
'downloads an user avatar'
do
allow_any_instance_of
(
Gitlab
::
ExclusiveLease
)
.
to
receive
(
:try_obtain
).
and_return
(
true
)
allow_any_instance_of
(
Gitlab
::
Geo
::
Avatar
Transfer
)
allow_any_instance_of
(
Gitlab
::
Geo
::
File
Transfer
)
.
to
receive
(
:download_from_primary
).
and_return
(
100
)
expect
{
subject
.
execute
}.
to
change
{
Geo
::
FileRegistry
.
count
}.
by
(
1
)
...
...
@@ -34,7 +34,7 @@ describe Geo::FileDownloadService, services: true do
it
'downloads a group avatar'
do
allow_any_instance_of
(
Gitlab
::
ExclusiveLease
)
.
to
receive
(
:try_obtain
).
and_return
(
true
)
allow_any_instance_of
(
Gitlab
::
Geo
::
Avatar
Transfer
)
allow_any_instance_of
(
Gitlab
::
Geo
::
File
Transfer
)
.
to
receive
(
:download_from_primary
).
and_return
(
100
)
expect
{
subject
.
execute
}.
to
change
{
Geo
::
FileRegistry
.
count
}.
by
(
1
)
...
...
@@ -50,7 +50,7 @@ describe Geo::FileDownloadService, services: true do
it
'downloads a project avatar'
do
allow_any_instance_of
(
Gitlab
::
ExclusiveLease
)
.
to
receive
(
:try_obtain
).
and_return
(
true
)
allow_any_instance_of
(
Gitlab
::
Geo
::
Avatar
Transfer
)
allow_any_instance_of
(
Gitlab
::
Geo
::
File
Transfer
)
.
to
receive
(
:download_from_primary
).
and_return
(
100
)
expect
{
subject
.
execute
}.
to
change
{
Geo
::
FileRegistry
.
count
}.
by
(
1
)
...
...
spec/services/geo/file_upload_service_spec.rb
View file @
916c9e7b
...
...
@@ -8,8 +8,8 @@ describe Geo::FileUploadService, services: true do
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
(
:params
)
{
{
id:
upload
.
id
,
type:
'avatar'
}
}
let
(
:
avatar_transfer
)
{
Gitlab
::
Geo
::
AvatarTransfer
.
new
(
upload
)
}
let
(
:transfer_request
)
{
Gitlab
::
Geo
::
TransferRequest
.
new
(
avatar
_transfer
.
request_data
)
}
let
(
:
file_transfer
)
{
Gitlab
::
Geo
::
FileTransfer
.
new
(
:avatar
,
upload
)
}
let
(
:transfer_request
)
{
Gitlab
::
Geo
::
TransferRequest
.
new
(
file
_transfer
.
request_data
)
}
let
(
:req_header
)
{
transfer_request
.
headers
[
'Authorization'
]
}
it
'sends avatar file'
do
...
...
@@ -32,8 +32,8 @@ describe Geo::FileUploadService, services: true do
let
(
:group
)
{
create
(
:group
,
avatar:
fixture_file_upload
(
Rails
.
root
+
'spec/fixtures/dk.png'
,
'image/png'
))
}
let
(
:upload
)
{
Upload
.
find_by
(
model:
group
,
uploader:
'AvatarUploader'
)
}
let
(
:params
)
{
{
id:
upload
.
id
,
type:
'avatar'
}
}
let
(
:
avatar_transfer
)
{
Gitlab
::
Geo
::
AvatarTransfer
.
new
(
upload
)
}
let
(
:transfer_request
)
{
Gitlab
::
Geo
::
TransferRequest
.
new
(
avatar
_transfer
.
request_data
)
}
let
(
:
file_transfer
)
{
Gitlab
::
Geo
::
FileTransfer
.
new
(
:avatar
,
upload
)
}
let
(
:transfer_request
)
{
Gitlab
::
Geo
::
TransferRequest
.
new
(
file
_transfer
.
request_data
)
}
let
(
:req_header
)
{
transfer_request
.
headers
[
'Authorization'
]
}
it
'sends avatar file'
do
...
...
@@ -56,8 +56,8 @@ describe Geo::FileUploadService, services: true do
let
(
:project
)
{
create
(
:empty_project
,
avatar:
fixture_file_upload
(
Rails
.
root
+
'spec/fixtures/dk.png'
,
'image/png'
))
}
let
(
:upload
)
{
Upload
.
find_by
(
model:
project
,
uploader:
'AvatarUploader'
)
}
let
(
:params
)
{
{
id:
upload
.
id
,
type:
'avatar'
}
}
let
(
:
avatar_transfer
)
{
Gitlab
::
Geo
::
AvatarTransfer
.
new
(
upload
)
}
let
(
:transfer_request
)
{
Gitlab
::
Geo
::
TransferRequest
.
new
(
avatar
_transfer
.
request_data
)
}
let
(
:
file_transfer
)
{
Gitlab
::
Geo
::
FileTransfer
.
new
(
:avatar
,
upload
)
}
let
(
:transfer_request
)
{
Gitlab
::
Geo
::
TransferRequest
.
new
(
file
_transfer
.
request_data
)
}
let
(
:req_header
)
{
transfer_request
.
headers
[
'Authorization'
]
}
it
'sends avatar file'
do
...
...
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