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
d6b691a4
Commit
d6b691a4
authored
Sep 11, 2018
by
GitLab Bot
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote-tracking branch 'upstream/master' into ce-to-ee-2018-09-11
parents
047b9072
c56f2b96
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
38 additions
and
12 deletions
+38
-12
app/uploaders/avatar_uploader.rb
app/uploaders/avatar_uploader.rb
+1
-1
changelogs/unreleased/51318-project-export-broken-when-avatar-is-set.yml
...leased/51318-project-export-broken-when-avatar-is-set.yml
+5
-0
lib/gitlab/import_export/avatar_restorer.rb
lib/gitlab/import_export/avatar_restorer.rb
+1
-1
spec/lib/gitlab/import_export/avatar_restorer_spec.rb
spec/lib/gitlab/import_export/avatar_restorer_spec.rb
+23
-10
spec/uploaders/avatar_uploader_spec.rb
spec/uploaders/avatar_uploader_spec.rb
+8
-0
No files found.
app/uploaders/avatar_uploader.rb
View file @
d6b691a4
...
...
@@ -19,7 +19,7 @@ class AvatarUploader < GitlabUploader
end
def
absolute_path
self
.
class
.
absolute_path
(
model
.
avatar
)
self
.
class
.
absolute_path
(
model
.
avatar
.
upload
)
end
private
...
...
changelogs/unreleased/51318-project-export-broken-when-avatar-is-set.yml
0 → 100644
View file @
d6b691a4
---
title
:
Fix broken exports when they include a projet avatar
merge_request
:
21649
author
:
type
:
fixed
lib/gitlab/import_export/avatar_restorer.rb
View file @
d6b691a4
...
...
@@ -19,7 +19,7 @@ module Gitlab
private
def
avatar_export_file
@avatar_export_file
||=
Dir
[
"
#{
avatar_export_path
}
/**/*"
].
fi
rst
@avatar_export_file
||=
Dir
[
"
#{
avatar_export_path
}
/**/*"
].
fi
nd
{
|
f
|
File
.
file?
(
f
)
}
end
def
avatar_export_path
...
...
spec/lib/gitlab/import_export/avatar_restorer_spec.rb
View file @
d6b691a4
...
...
@@ -6,22 +6,35 @@ describe Gitlab::ImportExport::AvatarRestorer do
let
(
:shared
)
{
project
.
import_export_shared
}
let
(
:project
)
{
create
(
:project
)
}
before
do
allow_any_instance_of
(
described_class
).
to
receive
(
:avatar_export_file
)
.
and_return
(
uploaded_image_temp_path
)
end
after
do
project
.
remove_avatar!
end
it
'restores a project avatar'
do
expect
(
described_class
.
new
(
project:
project
,
shared:
shared
).
restore
).
to
be
true
context
'with avatar'
do
before
do
allow_any_instance_of
(
described_class
).
to
receive
(
:avatar_export_file
)
.
and_return
(
uploaded_image_temp_path
)
end
it
'restores a project avatar'
do
expect
(
described_class
.
new
(
project:
project
,
shared:
shared
).
restore
).
to
be
true
end
it
'saves the avatar into the project'
do
described_class
.
new
(
project:
project
,
shared:
shared
).
restore
expect
(
project
.
reload
.
avatar
.
file
.
exists?
).
to
be
true
end
end
it
'saves the avatar into the project'
do
described_class
.
new
(
project:
project
,
shared:
shared
).
restore
it
'does not break if there is just a directory'
do
Dir
.
mktmpdir
do
|
tmpdir
|
FileUtils
.
mkdir_p
(
"
#{
tmpdir
}
/a/b"
)
allow_any_instance_of
(
described_class
).
to
receive
(
:avatar_export_path
)
.
and_return
(
"
#{
tmpdir
}
/a"
)
expect
(
project
.
reload
.
avatar
.
file
.
exists?
).
to
be
true
expect
(
described_class
.
new
(
project:
project
,
shared:
shared
).
restore
).
to
be
true
end
end
end
spec/uploaders/avatar_uploader_spec.rb
View file @
d6b691a4
...
...
@@ -35,5 +35,13 @@ describe AvatarUploader do
it_behaves_like
"migrates"
,
to_store:
described_class
::
Store
::
REMOTE
it_behaves_like
"migrates"
,
from_store:
described_class
::
Store
::
REMOTE
,
to_store:
described_class
::
Store
::
LOCAL
it
'sets the right absolute path'
do
storage_path
=
Gitlab
.
config
.
uploads
.
storage_path
absolute_path
=
File
.
join
(
storage_path
,
upload
.
path
)
expect
(
uploader
.
absolute_path
.
scan
(
storage_path
).
size
).
to
eq
(
1
)
expect
(
uploader
.
absolute_path
).
to
eq
(
absolute_path
)
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