Fix avatar saver and spec

This commit is contained in:
James Lopez 2018-07-10 16:23:45 +02:00
parent 874a4ff16a
commit 2c1e66d4d2
No known key found for this signature in database
GPG Key ID: 756BF8E9D7C0CF39
2 changed files with 9 additions and 5 deletions

View File

@ -11,7 +11,12 @@ module Gitlab
def save
return true unless @project.avatar.exists?
copy_files(avatar_path, avatar_export_path)
Gitlab::ImportExport::UploadsManager.new(
project: @project,
shared: @shared,
relative_export_path: 'avatar',
from: avatar_path
).copy
rescue => e
@shared.error(e)
false
@ -19,10 +24,6 @@ module Gitlab
private
def avatar_export_path
File.join(@shared.export_path, 'avatar', @project.avatar_identifier)
end
def avatar_path
@project.avatar.path
end

View File

@ -9,6 +9,7 @@ describe Gitlab::ImportExport::AvatarSaver do
before do
FileUtils.mkdir_p("#{shared.export_path}/avatar/")
allow_any_instance_of(Gitlab::ImportExport).to receive(:storage_path).and_return(export_path)
stub_feature_flags(import_export_object_storage: false)
end
after do
@ -18,6 +19,8 @@ describe Gitlab::ImportExport::AvatarSaver do
it 'saves a project avatar' do
described_class.new(project: project_with_avatar, shared: shared).save
puts "#{shared.export_path}/avatar/dk.png"
expect(File).to exist("#{shared.export_path}/avatar/dk.png")
end